Re: [Pyobjc-dev] Namespaces, intended behavior?
Brought to you by:
ronaldoussoren
From: Just v. R. <jus...@gm...> - 2018-04-05 16:43:11
|
> On 05 Apr 2018, at 18:12, Ronald Oussoren <ron...@ma...> wrote: > > > >> On 5 Apr 2018, at 17:39, Just van Rossum <jus...@gm...> wrote: >> >> Hi, >> >> I am wondering, is the following intended behavior? >> >> ------------- >> import Foundation >> >> class TestMyCustomObject(Foundation.NSObject): >> pass >> >> import AppKit >> # it's suddenly available via AppKit: >> print(AppKit.TestMyCustomObject) >> # even via import *: >> from AppKit import * >> print(TestMyCustomObject) >> ------------- >> >> Thanks, > > That is expected behavior and is a side effect of lazy loading of frameworks. > > In the past I have attempted to expose only the classes that belong in a framework (by exposing only those classes located in the correct framework bundle), but that code turned out to be too slow (because the Cocoa method I used for that is slow), so that got dropped a long time ago. When I started on the lazy loader I didn’t even try to make it guess whether or not a class should be loadable through the current framework wrapper. This is not ideal, but good enough. Thanks for the clarification. That does mean that one should pretty much never ever do from SomeFramework import * Despite the fact that most frameworks have decent prefixes for their sybols. Just |