import structures
Duncan Booth
duncan.booth at invalid.invalid
Mon Apr 30 11:35:03 EDT 2007
spohle <spohle at gmail.com> wrote:
> as of now i have a __init__.py file in the directory with:
> from pkgutil import extend_path
> __path__ = extend_path(__path__, __name__)
>
> but i still have to import each class by it's own. im really looking
> for something like import wx
> and then get all my access right away under this new namespace.
You just need to make your __init__.py import anything you want to be
available directly under the package.
So if the folder pkg contains __init__.py, class1.py, class2.py all you
have to do is make pkg/__init__.py contain something like:
from class1 import Class1
from class2 import Class2
And then when using the package you can do:
from pkg import Class1, Class2
or
import pkg
...
something = pkg.Class1()
as you prefer.
More information about the Python-list
mailing list