<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Dear all,<br><br>I am building a library package of the form:<br><br>rootlib<br>---__init__<br>---subpackage1<br>------__init__<br>------sub1module1<br>------sub1module2<br>------...<br>---subpackage2<br>------ __init__<br>------sub2module1<br>------sub2module2<br>------...<br><br>My rootlib.__init__ file contains:<br>
<br>
__name__        = ...<br>
__version__     = ...<br>
__author__      = ...<br>
__author_email__= ...<br>
__url__         = ...<br>
__description__ = ...<br>
 <br>
import subpackage1<br>
import subpackage2<br>
<br>
__all__ = []<br>
__all__.extend(['subpackage1','subpackage2'])<br><br>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.<br><br>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...<br><br>Can anyone give me a hint ?<br><br>Cheers,<br><br>Auré<br><br></div>
</div><br>




      </body></html>