Correctness: sys.path.append("..")

Jeremy Bowers clp at jerf.org
Thu Jan 10 00:49:26 EST 2002


The upshot of this thread seems to be that if try to create a 
directory structure like

MainProject/
    UI/
    DataStructures/
    FileLoaders/

such that files in the UI directory can import files in the DataStructures
directory, the only "correct" way to do this is to make sure that the parent
of MainProject is on the PYTHONPATH.

Mucking with sys.path still seems somehow wrong, but is a superior solution
IMHO to enforcing the idea that my program must be installed in a rather
limited set of directories, or the user has to muck with an environment
variable (when many users have no idea such a thing exists).

I'd complain, but the language is up to 2.2 and it doesn't seem to bother
anyone else.  :-)

Despite the wrongness, I'm going with the os.absolute_path("..") solution.
Both projects are pure Python and my goal is to get installation directions
down to

* Install Python if necessary
* Uncompress my program's archive file
* Double-click/invoke in an OS-appropriate manner MainProg.py

Thanks for the help, everyone.




More information about the Python-list mailing list