Dear all,
I am building a library package of the form:
rootlib
---__init__
---subpackage1
------__init__
------sub1module1
------sub1module2
------...
---subpackage2
------ __init__
------sub2module1
------sub2module2
------...
My rootlib.__init__ file contains:
__name__ = ...
__version__ = ...
__author__ = ...
__author_email__= ...
__url__ = ...
__description__ = ...
import subpackage1
import subpackage2
__all__ = []
__all__.extend(['subpackage1','subpackage2'])
My question is the following: I need to import an external package, say numpy,
for use in various submodules. So far, I simply do an import numpy as _numpy
where needed, say sub1module1 and sub2module2. This means that I import this
package a number of times which doesn't seem to be a logical thing to do (?).
In the end, I would like to make this module a "global" module for my library.
I would find it more practical to simply do this import in the __init__ of
rootlib and then use it directly in the submodules as rootlib._numpy calls, but
I'm not sure exactly how to do this because it would mean that I would have to
do an import rootlib in my subpackages which doesn't sound so good...
Can anyone give me a hint ?
Cheers,
Auré
--
http://mail.python.org/mailman/listinfo/python-list