Duncan Booth wrote: > iu2 <[EMAIL PROTECTED]> wrote: > >> file a3.py: >> ======== >> from a1 import the_number >> import a2 >> > ... >> Why doesn't it work in the first version of a3.py? >> > Think of 'import a2' as being the same as: > > a2 = __import__('a2') > > and 'from a1 import the_number' as roughly the same as: > > the_number = __import__('a1').the_number > > In other words think of them as assignments and it should all make sense. >
This is a little surprising. So "from mod import *" really copies all of the scalars into new variables in the local namespace. The same is true with object pointers I suppose, but this is transparent as all the copies access the same object. I always ASSumed that the two forms of import were equivalent, but that one form did away with the need to be explicit about the namespace: mod.thing Obviously this is far from the case. -- Posted via a free Usenet account from http://www.teranews.com -- http://mail.python.org/mailman/listinfo/python-list