473,706 Members | 2,545 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.framewor k/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 1527
"ariza" <ar***@flexaton e.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.framewor k/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.framewor k/Versions/2.3/lib/python2.3'

can we assume that, on all platforms, the old site.here is the same as:
os.path.join(sy s.prefix, 'lib', 'python%s' % sys.version[:3]) '/System/Library/Frameworks/Python.framewor k/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.framewor k/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
1429
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 /usr/lib/python2.4/site-packages, but I also had to install a newer PyXml package, as some of the files that came with python2.4 required a newer version of pyxml than I had in python2.3/site-packages. I wonder if there is any particular reason I...
1
1624
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 something like this: <td id="portal-column-one" metal:define-slot="column_one_slot" tal:define="sectionlevel " tal:condition="<if home/main page of plone site hide this column>">
48
2462
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, currently Windows but considering FreeBSD 2. Site consists of result pages for auctions and items for sale (100 per page) 3. MySQL (Dell Poweredge w/AMD) database server connected to my web server
3
1162
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. * Construction of re's is object oriented, and does not require any knowledge of re syntax. * rex is _very good_ at combining small re's into larger re's. In fact, this sort of composition is almost effortless. It greatly simplifies the creation of...
20
4276
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 is structured as an upside-down tree, and (if I remember correctly) never more than 4 levels. The site basically grew (like the creeping black blob) ... all the pages were created in Notepad over the last
6
2058
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 than the maximum. This is happening in the convertsimple() routine when it tries to return a signed int:
1
1747
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 python script seems to be designed for 'non database' sites, not a site which is using .asp, and has dynamic pages. We are an ecommerce site. What are other ecommerce sites using to create an xml file? Are they using the python script?
9
2095
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 directory) with a 100% reliable method... My goal is to verify if an/several extension(s) are installed and to automatically install the missing ones on Linux or Win32.
6
2117
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 want to host a site where people can register to become a user. They should be able to maintain their own "showroom", where they can show blog entries (maybe just by linking to their own blogs on some other blog/album-hosting site like Xanga), put...
0
8773
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8692
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9042
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8983
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4705
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2495
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.