site.here on python 2.4

ariza ariza at flexatone.com
Thu Jan 13 11:53:15 CET 2005


i am not sure where i found site.here documented as used prior to 2.4.

the issue is that i do not need sys.path, as in the list of all paths
that python searches. sys.prefix is close to what i need:

>>> sys.prefix
'/System/Library/Frameworks/Python.framework/Versions/2.3'

but the old site.here gave sys.prefix, plus the additional directories
to get into the actual python library:

>>> site.here
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3'

can we assume that, on all platforms, the old site.here is the same as:

>>> os.path.join(sys.prefix, 'lib', 'python%s' % sys.version[:3])
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3'

or is it better to use, as you suggest,

>>> import os
>>> os.path.dirname(os.__file__)
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3'

this is useful for a few reasons. the first was i needed a cross
platform way to find the complete path to the idle directory; the
second was the complete path to the 'site-packages' directory.

thanks!




More information about the Python-list mailing list