benjamin.kaplan at case.edu
Sun Dec 14 21:27:57 CET 2008
On Sun, Dec 14, 2008 at 3:16 PM, Torsten Mohr <tmohr at s.netic.de> wrote:
> in a package i'd like to have a structure like this:
> Files end with ".py", others are directories:
> __init__.py # sets __all__ = ['smod1']
> smod1.py # contains AClass()
> __init__.py # sets __all__ = ['abc', 'def']
> So i can now do:
> import mod.smod1.abc
> import mod.smod1
> But functions/classes in smod1.py are not found:
> a = mod.smod1.AClass()
> I know this is somehow ambiguous, but i wonder how else i can make
> "mod" have subpackages and modules.
> I wonder how i can make AClass() known in that package.
You have two modules named smod1- one of them uses the code in smod1.py, the
other one is in smod1/__init__.py. The second one hides the first. Python
doesn't let you have two modules with the same name. You have to either
rename one of the smod1's or define AClass in smod1/__init__.py instead.
> Thanks for any hints,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list