__import__ confusion
Leazen
leazen at uol.com.ar
Mon Feb 24 22:41:04 EST 2003
Hi,
I'm having some trouble understanding how __import__ works.
From the docs I read that "from spam.ham import eggs" results in
"__import__('spam.ham', globals(), locals(), ['eggs'])" rendering the
later function call 'eggs', what ever that is, but I actually get 'ham'!
For example:
>>> __import__('os.path', globals(), locals(), 'join')
<module 'ntpath' from 'C:\Python22\lib\ntpath.pyc'>
So I wonder what the last argument is for since it seams rather
useless. I could'va just written:
>>> __import__('os.path', globals(), locals(), 'asdfasdfasf')
<module 'ntpath' from 'C:\Python22\lib\ntpath.pyc'>
Now I realize that the last argument should be a list but that doesn't
seam to make a difference.
Any enlightment would be welcome.
Regards,
Leazen
More information about the Python-list
mailing list