473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

site.here on python 2.4


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:
import site
site.here

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

i do not see any information about this change save that in the new
documentation it says:

"""
This module is automatically imported during initialization. The
automatic import can be suppressed using the interpreter's -S option.

Importing this module will append site-specific paths to the module
search path.
"""

can anyone propose a similarly effective and cross-platform solution
for easily discovering the the library path on any python installation?

Jul 18 '05 #1
2 1510
"ariza" <ar***@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>

Jul 18 '05 #2

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!

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: enrio | last post by:
I recently installed python 2.4, and many installed software packages stopped working. Some things got working after I copied some files and directories from /usr/lib/python2.3/site-packages to...
1
by: Paul Ertz | last post by:
Hello, We would like to hide the left column for the main/home page of our plone sites dynamically using a tal: expression. I figured out that I need to customize the main_template file...
48
by: northband | last post by:
Hi, I am interested in re-writing my website in Python vs PHP but have a few questions. Here are my specs, please advise as to which configuration would be best: 1.Dell Poweredge Server, w/IIS,...
3
by: Kenneth McDonald | last post by:
Over the last couple of years, I've built a module called rex that lays on top of (and from the user's point of view, hides) the re module. rex offers the following advantages over re. *...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
6
by: bhochstetler | last post by:
I am on a hp 11.11 machine doing a 64 bit python 2.5 build. When I get my python executable created and run it, I get the error: "import site failed" OverflowError: signed integer is greater...
1
by: michael.buonomo | last post by:
We have been using the Google recommended python script for about a year. We recently realized that the script was not crawling our sites url's, but just our folders which reside on the server. The...
9
by: pythonewbie | last post by:
Hi all, I am newbie in Python, my wish would be to create python applications for both Linux/Win32. I am stucked on creating a function to get the Python install directory (and site-packages...
6
by: Magdoll | last post by:
Hi, I know this is potentially off-topic, but because python is the language I'm most comfortable with and I've previously had experiences with plone, I'd as much advice as possible on this. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.