M
Marco Herrn
Hi,
I am using the builtin __import__() to import modules. That works for
simple modules like in this example:
m= __import__("eggs")
when there is the module "eggs.py" in the current directory
But how do I do this with packages? A I understand the documentation for
__import__(), it must be something like:
m= __import__("eggs", globals(), locals(), ["spam"])
when there is the package "spam" in the current directory, containing
the module "eggs".
But that doesn't work. I tried it in some different forms. The only one
that works in some way is:
m= __import__("spam.eggs")
But that is not what I want, since I get "spam" as a module:
<module 'spam' from 'spam/__init__.pyc'>
So what am I doing wrong here?
Marco
I am using the builtin __import__() to import modules. That works for
simple modules like in this example:
m= __import__("eggs")
when there is the module "eggs.py" in the current directory
But how do I do this with packages? A I understand the documentation for
__import__(), it must be something like:
m= __import__("eggs", globals(), locals(), ["spam"])
when there is the package "spam" in the current directory, containing
the module "eggs".
But that doesn't work. I tried it in some different forms. The only one
that works in some way is:
m= __import__("spam.eggs")
But that is not what I want, since I get "spam" as a module:
<module 'spam' from 'spam/__init__.pyc'>
So what am I doing wrong here?
Marco