import package w/ all subpackages?

Ulrich Petri ulope at gmx.de
Sun Mar 30 07:43:07 EST 2003


"Your Mom" <yourmom at hotmail.com> schrieb im Newsbeitrag
news:f9sha.3283$yh1.433534 at news1.east.cox.net...
>     There doesn't seem to be a built-in way to import a package w/ all
it's
> subpackages & modules.  Does anyone else see value in adding a statement
> like "import fully foolib"?
>
>     I've developed a package that (in trying to keep its contents
organized
> properly) has ended up with a number of modules & subpackages.  Currently,
a
> typical program attempting to use my package needs to run 'import
> foolib.foo, foolib.bar, foolib.baz' for each component to be used.  I've
> determined that i *could* make things easier by adding 'import foo, bar,
> baz' in the __init__.py file; however, this forces all programs using a
> single component from the package to import them all, requiring that any
> depency of any of those components be installed.  Wouldn't it be nice to
for
> scripts that want everything in a package to be available for use to say
> something along the lines of "import fully foolib", while letting other
> scripts pick modules ala cart?  Just a thought, anyway...

Hi,

imho you should put the imports into __init__ since one can still select if
he does not want to import all stuff by means of:

from foolib import baz

Ciao Ulrich






More information about the Python-list mailing list