Confused about namespaces

Chris Mellon arkanes at gmail.com
Sat Nov 19 01:23:11 CET 2005


On 18 Nov 2005 16:09:44 -0800, KvS <keesvanschaik at gmail.com> wrote:
> Hmm. But actually I was doing this import from GUIclasses with exactly
> this in mind, namely that it would make wx also available at top level.

There's no reason not to just "import wx" if you want that.

> I (in my naive understanding) see this as "natural" and actually
> desirable, how could this cause confusing bugs? Do you mean multiple
> "from ... import *"'s 'on top of each other' would cause foo1.foo2.attr
> and foo1.attr both would become just attr and therefore ambiguous at
> top level?

the second import will overwrite the first, making the first inaccessible

>
> If you import foo in two different modules, does the interpreter then
> create one instance of foo and create a reference in both modules to
> the same foo rather than creating two different instances of foo?
>

No. It creates the foos within each module, but which foo you have
access to in the importing module is determined by the order of
import.

> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list