intra-module dependencies

Joey Tsai joeytsai at gehennom.net
Wed Nov 19 19:40:46 EST 2003


Assuming you have two directories of modules:

project/lib
project/filters

How can functions in "filters" reference functions in "lib"?  Right now
I have in the files in filters:

sys.path.append( ".." )
import lib

But that's kinda ugly.  Section 6.4 in the python tutorial says that if
I'm in the project/filters directory I should be able to access lib
like:
import project.lib

But that doesn't work if I'm running python scripts in the
project/filters directory.  Is there any nicer way to do this?

Basically, I have a "main" project file that uses things in both lib and
filters, so normally I don't have this problem, but I want the filters
to be able to run by themselves.

Thanks!  Please CC to me, I'm not subscribed

-- 
      joey tsai       |       A witty saying proves nothing.
                      |                                       -- Voltaire





More information about the Python-list mailing list