Re: import structures
- From: spohle <spohle@xxxxxxxxx>
- Date: 30 Apr 2007 08:24:37 -0700
On Apr 30, 8:16 am, "Hamilton, William " <wham...@xxxxxxxxxxx> wrote:
-----Original Message-----[mailto:python-
From: python-list-bounces+whamil1=entergy....@xxxxxxxxxx
list-bounces+whamil1=entergy....@xxxxxxxxxx] On Behalf Of spohle
Sent: Monday, April 30, 2007 10:03 AM
To: python-l...@xxxxxxxxxx
Subject: Re: import structures
On Apr 30, 8:00 am, Paul McGuire <p...@xxxxxxxxxxxxx> wrote:
On Apr 30, 9:56 am, spohle <spo...@xxxxxxxxx> wrote:
hi,
andi have written a small project for myself all in seperate classes
aneach of the classes lives in a seperate file. now i am looking for
allimport structure something like import wx, and then have access to
my classes just like wx.Button or wx.BoxSizer etc.
as of now i have a __init__.py file in the directory with:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
lookingbut i still have to import each class by it's own. im really
for something like import wx
and then get all my access right away under this new namespace.
thank you in advance
classesIf it really is a small project, consider just putting all the
importinto a single module, say spohlePkg.py. Then your users would
asthis module using "import spohlePkg", and would access the classes
"spohlePkg.ClassA", "spohlePkg.ClassB", etc.
-- Paul
yeah i had that, but my classes grew really fast and i decided to
split them up. but you're right that in one file that would solve my
problem. still hoping to find a way for the seperate files.
If you've got modules a, b, and c, you can create a wrapper module d
that imports from each of those.
from a import *
from b import *
from c import *
Then, import d and use it as the module name. So if a had a SomeThing
class, you could do this:
import d
x = d.SomeThing()
---
-Bill Hamilton
that doesn't seem to work for me. the from a import * will only give
me a not d.a
.
- Follow-Ups:
- RE: import structures
- From: Hamilton, William
- RE: import structures
- References:
- Re: import structures
- From: spohle
- RE: import structures
- From: Hamilton, William
- Re: import structures
- Prev by Date: Re: regexp match string with word1 and not word2
- Next by Date: Re: import structures
- Previous by thread: RE: import structures
- Next by thread: RE: import structures
- Index(es):