How to simulate packages?

Daniel daniel.watrous at
Thu Aug 21 18:04:51 CEST 2008


I have a project that I've decided to split into packages in order to
organize my code better.  So what I have looks something like this


Everytime I run I need to import  Right now
I'm using an ugly little thing to do my import (see below).  Isn't
there some python mechanism to handle packages?

import os, sys
# add packages to path then finish importing
for dir in ['module1','module2']:
    # how about this ugly thing to find adjacent directories for
[:len(os.path.dirname(__file__).split('\\'))-1]) + "\\" + dir)

Any and all suggestions appreciated.  Thanks in advance.


More information about the Python-list mailing list