handling modules in packages

Daniel Larsson daniel.j.larsson at gmail.com
Wed Sep 5 10:14:57 EDT 2007


On 9/5/07, Tommy Grav <tgrav at mac.com> wrote:
>
> >>
> > The simplest thing to do would be to have PyAstro.__init__.py
> > import all
> > the sub-modules, and define __all__ as the set of names that the
> > package
> > should inject into importing modules.
> >
> > Then you could write (for example)
> >
> > from PyAstro import numpy, constants, conversion, obsrvations
> >
> > However if you are simply worried about run-time efficiency then don't
> > be: once a module is imported further imports essentially reduce to
> > checking that the module is already present in the sys.modules
> > dict, and
> > so take almost no time at all.
>
> So am I understanding it right that a second import numpy statement
> in a different module (and thus a different namespace) just results in
> a binding to the already existing numpy "object"?


Yes, correct
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070905/6f1417ca/attachment.html>


More information about the Python-list mailing list