python packages cross references

Jeff Shannon jeff at ccvcorp.com
Tue Aug 17 15:33:01 EDT 2004


Roman Yakovenko wrote:

>May be I was not clear, but from module in package A I want to user functionality
>defined in module of package Utils
>
>"...
>When packages are structured into subpackage (as with the Sound package in the example), there's no shortcut to refer to submodules of sibling packages - the full name of the subpackage must be used. For example, if the module Sound.Filters.vocoder needs to use the echo module in the Sound.Effects package, it can use from Sound.Effects import echo. 
>...
>"
>It means that I should have prj in sys.path. ( Am I wrong here? ).
>
>So I ask is there is elegant solution?
>  
>

Uh, whatever you'd do to get prj into your sys.path in order to run your 
program to begin with?  Actually, technically speaking, you don't need 
prj in sys.path, you only need the directory that prj is under in your 
sys.path -- if Python can see the prj directory, it'll look inside it 
for an __init__.py, and finding that will consider it a valid package.  
In recent versions (certainly 2.2+) of Python, I believe that you 
*should* be able to simply put prj under %python-lib%/site-packages 
(wherever that may be located on your particular installation), which is 
already in sys.path and is intended for that very purpose.

Jeff Shannon
Technician/Programmer
Credit International




More information about the Python-list mailing list