import package w/ all subpackages?

Carl Banks imbosol-1049063178 at
Mon Mar 31 00:38:09 CEST 2003

Michael McFarland wrote:
>   Carl's solution would certainly work for when I want *my* code to import
> a full package (although I still don't think "foolib =
> import_fully('foolib')" looks as clean as "import fully foolib").  But I'm
> thinking in terms of making the interface to my complex package as useful as
> possible to other people (who won't have access to this 'import_fully'
> function).  I suspect that over time, as more python packages grow (like the
> 'mx' package), there will be more of a need for all python users to have
> some built-in way of doing a "import fully mx".

I disagree with your suspicion: most people will just import the
packages they need, *especially* with packages growing.  Who the hell
needs the whole MX library at once?  I think it's a fringe concern
that doesn't justify having it's own syntax, and anyone needing this
can Google for import_fully themselves.

If you're writing a package that you think it might be useful to
import fully, then provide the function to do it in the package.  Make
it so someone can do something like this:

    import foolib

Don't worry about whether it looks clean.  Most little tasks don't
have the privledge of looking as clean as you would like; that's life;
just live with it.


More information about the Python-list mailing list