Distutils: blurring the file==module borders
Delaney, Timothy C (Timothy)
tdelaney at avaya.com
Mon Jan 24 21:15:52 EST 2005
Frans Englich wrote:
> in ./foo/ I have an __init__.py and a handful of files named
> ClassA.py, ClassB.py, ClassC.py and so forth.
>
> import foo.ClassA
>
> var = foo.ClassA.ClassA()
>
> while I want to do var = foo.ClassA()
>
> In other words, the result I want can be achieved by putting all code
> in __init__.py. The problem is that I would find it horrible to have
> all code in one file.
# __init__.py
from foo.ClassA import ClassA
That brings the class 'ClassA' into the namespace of module 'foo'
(replacing module 'ClassA' as a side effect - if you don't want that,
change some names).
Tim Delaney
More information about the Python-list
mailing list