site.here on python 2.4
Fredrik Lundh
fredrik at pythonware.com
Thu Jan 13 04:58:32 EST 2005
"ariza" <ariza at flexatone.com> wrote:
> greetings. it seems that the attribute site.here, of the site module,
> has vanished in python 2.4. up until python 2.3, site.here seemed (to
> me at least) a convenient way to get the complete path to the python
> library on any platform.
"here" was a temporary variable used to get the exact location of
the LICENSE file. in Python 2.4, that code has been moved into
a function, in which "here" is still a temporary variable.
was it documented somewhere else?
> can anyone propose a similarly effective and cross-platform solution
> for easily discovering the the library path on any python installation?
the library path is defined by the sys.path variable, which contains a list
of library directories.
sys.prefix gives you the installation root, sys.executable tells you where
the interpreter is.
if you need the exact behaviour of "site.here", you can do
import os
here = os.path.dirname(os.__file__)
but I don't really see why your program should have to care about
anything but the path...
</F>
More information about the Python-list
mailing list