creating package question

Micah Elliott mde at
Wed Nov 16 21:29:12 CET 2005

On Nov 16, erick_bodine at wrote:
> I have a package directory structure as follows
> root-
>     |
>     Common (contains file)
>     WindowsComponents (contains file)
>     ...
> I would like modules in the WindowsComponents directory to be able
> to import some modules from the Common directory.

So you now have a "Common" package.  And it might contain a "mustard"

> In my first pass, I was able to append sys.path (
> sys.path.append('../Common') ) in each module that wants to import
> from Common, but this feels "clunky".

Agreed.  You probably want to avoid messing with sys.path whenever

> Is there a "standard"/"best" way to accomplish this?  

So "root" should already be on your sys.path/PYTHONPATH.

Then in say file "root/WindowsComponents/":

    from Common import mustard

More import info from Fredrik:

_ _     ___
|V|icah |- lliott             <><             mde at
" "     """

More information about the Python-list mailing list