Question on making names visible in packages

Sean Ross sross at connectmail.carleton.ca
Sun Mar 14 22:32:31 CET 2004


"Kenneth McDonald" <kmmcdonald at wisc.edu> wrote in message
news:slrnc59er9.3hp.kmmcdonald at g4.gateway.2wire.net...
[snip]
>
> import Package
>
> and then to use the classes as
>
> Package.Class1, Package.Class2, etc.
>
> However, I'm only able to get this behavior when I leave the
> class definitions in the __init__.py file. When in other files,
> they of course have to be referenced as :
>
> Package.filename.Class1
>
> Is there some way of making the names visible at the top level
> of the module, to mask the fact that they are split amongst
> different files within the package?
[snip]

In your __init__.py you can add :

from filename import Class1

to make the names visible at the top-level.

HTH
Sean







More information about the Python-list mailing list