[Pythonmac-SIG] simple help?

Ronald Oussoren ronaldoussoren at mac.com
Tue Mar 7 18:00:48 CET 2006


On 7-mrt-2006, at 17:49, Samuel M. Smith wrote:

> I use PYTHONPATH to add my own python development directories so that
> modules I create myself or don't want to install in the default:
> /library/frameworks/python.framework/versions/2.4/lib/python2.4/site-
> packages/

The time machine strikes again :-). You can also install your own
packages in ~/Library/Python/2.4/site-packages. That directory is
a proper site-package, .pth files work in there.

[...]
>
> So the stuff you put in PYTHONPATH get prepended to the list of
> places python looks into for modules when you
> do an import.
>
> I don't know how the other stuff (besides what is in PYTHONPATH) gets
> assigned to the sys.path variable. But
> apparently different package installers know how to assign stuff to
> sys.path.

It is initialised to the directory containing the script followed by  
the python library.
PYTHONPATH is then prepended to sys.path. site.py will then add the  
site packages
directories to sys.path. The contents of .pth files in the site  
packages directories
is then added sys.path (again by site.py).

That's how package installers update your sys.path: they install .pth  
files.

Ronald




More information about the Pythonmac-SIG mailing list