[Pythonmac-SIG] import question

Louis M. Pecora pecora at anvil.nrl.navy.mil
Fri Nov 7 07:37:31 EST 2003


>
>IMHO, PYTHONPATH is a crutch and should rarely be used.  What you 
>should do, for most situations, is to create "pth" files in your 
>existing sys.path .. for example, in my /Library/Python/2.3, I have 
>a file aeve.pth which contains (only) the following text 
>"/Users/bob/svn.undefined.org/aeve" sans quotes.  What this means, 
>is when the python interpreter starts (if it finds site.py, of 
>course, which is almost all the time) it will add 
>/Users/bob/svn.undefined.org/aeve to sys.path and find any 
>modules/packages in that directory.
>
>-bob

Bob,

I have been messing with PYTHONPATH because I thought that was the 
way to do it.  What I did was create the directory .MacOSX and then 
the plist file Environment.plist using the Prefs editor in the 
Appledevelopment tools, although any test editor will do if you know 
XML (I don't) or if you create the file, then re-editing is easy. 
Environment.plist looks like this when I'm done:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>PYTHONPATH</key>
	<string>/users/louispecora/Code/python/general:/users/louispecora/Code/python/plotwindow</string>
</dict>
</plist>


I have two paths defined:
/users/louispecora/Code/python/general
/users/louispecora/Code/python/plotwindow

so I can import my modules from them.

To add more I just open the file and colon-separate additional paths.

Now you're telling me that through sys.path there's this other way. 
Is that anywhere in the docs so I can understand it more?

Thanks.

-- 

Cheers,

Lou Pecora




More information about the Pythonmac-SIG mailing list