import woe

vaibhav vaikings at gmail.com
Fri May 19 02:24:00 EDT 2006


Hi bob,

1. decide the directory which will be your root folder containing foo
[/home/ROOT/foo/]

2. work out your directory structure relative to this root folder
 here it is ->ROOT->foo->car.py
                                   ->bar->far.py
                                   ->bar->jar.py

3. add __init__.py file inside each folder containing a list variable
__all__ with contents as the name of the directories and classes
so foo folder should contain a file called __init__.py which has the
following contents
__all__ = ['bar','car']
and bar folder should contain a file called __init__.py which has the
following contents
__all__ = ['far','jar']

4. add the root folder to your sys.path
so your jar.py file should have the  following entries
from sys import path
path.append('../../../ROOT')

note: i prefer relative paths or make paths using os.getcwd
combinations in such situations, which makes the class more flexible.
you can also do this step where u configure/initialize

5. then you can import the classes you want in jar.py

from foo import car
from foo.bar import far

pls mail if u dont get it working/any doubts.  

-
vaibhav




More information about the Python-list mailing list