namespace and reloading (was Re: PythonWin IDE sucks!)
hzhu at users.sourceforge.net
Wed Nov 1 23:01:59 CET 2000
On Tue, 31 Oct 2000 15:37:15 -0500, Jason Cunliffe <jasonic at nomadicsltd.com>
>...surely these are not the same?
>>>> from module import object
>puts 'object' directly into the namespace doesn't it, so one would use
>But in the second case
>>>> import module
>means that one would then use
They are not the same. The former get object into you current name space so
it is quicker to look up but difficult to update. The latter leaves it in
module name space so it's less clutter, and easier to update.
>I suppose my question is:
>When you use >>> from module import object
>#forget import module compeletely for the moment
>how do you do reload()?
AFAIK, you can't do directly. You have to import module; reload(module);
from module import object.
>It seems to me the cleanest way is to use the more verbose "import module"
>But there are many famous exceptions, such as wxPython Tutorials
>>>> from wxPython.wx import *
Some packages are written with this intention in mind, so the names are less
likely to confict. Since these are ready-made packages you generally
wouldn't want to reload anyway.
I think that once you do "from module import *" there's no way to find out
which name in your current name space came from which module. (Somebody
please confirm this as I'm not completely sure.) So if you want to update
them all you have to redo "from ...".
More information about the Python-list