packages using a class in the parent directory ?

Stephen shriek at gmx.co.uk
Tue Dec 25 21:23:43 EST 2001


Instead of having a directory full of 30-40 python scripts, 
I'm trying to package them according to functionality, such as ~ 

app1.py
app2.py
message.py
/Folder1 
   - __init__.py 
   - a.py
   - b.py
   - c.py
   ... etc
/Folder2 
   - __init__.py
   - x.py
   - y.py
   - z.py 

where the main apps sit in the base directory and components
that they use are packaged in the folders.

The only problem is that some of the python scripts in the 
subdirectories (ie. in Folder1 & Folder2) need to use a base
class ('message.py' above).  So, how can the packaged scripts
import the class ? 

The solutions seem to be ~
a) copy message.py to Folder1 and Folder2 but then we have to
   make sure that all copies of the file are kept in sync
b) symlink message.py to each folder, but that doesn't work on 
   win32 even with the cygwin tools.
c) add message.py to the sitewide import path, but I try to
   avoid that wherever possible to ease portability (easy to
   just copy over the folder and it works).

Is there a better way ? 

Thank you,

Stephen.



More information about the Python-list mailing list