import package w/ all subpackages?

Ulrich Petri ulope at
Sun Mar 30 14:43:07 CEST 2003

"Your Mom" <yourmom at> schrieb im Newsbeitrag
news:f9sha.3283$yh1.433534 at
>     There doesn't seem to be a built-in way to import a package w/ all
> 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
> properly) has ended up with a number of modules & subpackages.  Currently,
> typical program attempting to use my package needs to run 'import
>,, 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 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
> 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...


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