Re: import structures
- From: Duncan Booth <duncan.booth@xxxxxxxxxxxxxxx>
- Date: 30 Apr 2007 15:35:03 GMT
spohle <spohle@xxxxxxxxx> 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.
.
- References:
- import structures
- From: spohle
- import structures
- Prev by Date: Re: import structures
- Next by Date: Re: regexp match string with word1 and not word2
- Previous by thread: RE: import structures
- Next by thread: Can python find HW/SW installed on my PC - like Belarc?
- Index(es):
Relevant Pages
|