473,320 Members | 2,088 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,320 software developers and data experts.

.pth files question

Am I correct in understanding that:

1) foo.pth will be used if it is in the directory
/usr/lib/python-2.4/site-packages

2) foo.pth will not be read from if it is only placed somewhere in the
PYTHONPATH environment, such as foo.pth exists as the file
/tmp/bar/foo.pth, where PYTHONPATH contains "/tmp/bar"?

Thanks,
--
Benjamin Rutt
Sep 2 '05 #1
2 1356
Benjamin Rutt wrote:
Am I correct in understanding that:

1) foo.pth will be used if it is in the directory
/usr/lib/python-2.4/site-packages

2) foo.pth will not be read from if it is only placed somewhere in the
PYTHONPATH environment, such as foo.pth exists as the file
/tmp/bar/foo.pth, where PYTHONPATH contains "/tmp/bar"?


Yes. All this is done by the site module.
--
Michael Hoffman
Sep 2 '05 #2
Benjamin Rutt wrote:
Am I correct in understanding that:

1) foo.pth will be used if it is in the directory
/usr/lib/python-2.4/site-packages

2) foo.pth will not be read from if it is only placed somewhere in the
PYTHONPATH environment, such as foo.pth exists as the file
/tmp/bar/foo.pth, where PYTHONPATH contains "/tmp/bar"?


Both by inspection of the source and by experimentation, it appears you
are correct. As the docs say, only the "site-specific paths" (i.e.
sys.prefix and sys.exec_prefix, and lib/python<version>/site-packages
and lib/site-python) are actually scanned for .pth files, plus any paths
added as a result of parsing .pth files that are found.

If you want to modify or extend this behaviour, you should take
advantage of sitecustomize.py by adding your own behaviour, perhaps
scanning os.environ['PYTHONPATH'] to look for .pth files.

-Peter
Sep 2 '05 #3

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

Similar topics

44
by: Xah Lee | last post by:
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical, but you don't know which ones are...
13
by: | last post by:
Although this question does not belong in here, I hope someone help, as I do not know where to send it, but someone here might have come acros similar problem: Some of JPG files sitting in the...
15
by: miki | last post by:
hello, I was asked this question during a job interview, and didn't know the answer. could someone please help me with that? the question was: "Which files are more suitable for working in C,...
6
by: Hans Kesting | last post by:
Hi, When I add a webform, VS generates three files: WebForm1.aspx WebForm1.aspx.cs (could also be "WebForm1.aspx.vb" I guess) WebForm1.aspx.resx What is that last file for? How can I use...
7
by: Alan Silver | last post by:
Hello, I am just looking at VWD and seeing what needs doing to take an existing site I've written by hand and importing it into VWD. I've already discovered that I need to rename my code-behind...
4
by: feng | last post by:
Hi, I need to implement a function, GetAllFiles, of a web service that once called, returns all the files in a folder to the caller. My question is: what is the best way to implement this...
4
by: Shiraz | last post by:
Hi I'm using Visual Studio Installer to make my installer, and have not as yet figured out a straightforward way to use it to set environmental variables. Amongst the various things I tried, I'm...
15
by: leorulez | last post by:
Is there any way to read multiple files (more than 1000 files) and then write into one single output file using C? Right now in my program, I have a loop which asks for the filename and writes into...
2
by: key9 | last post by:
Hi all look at the organize tree main.c ------ #include lib_adapter.c main() { foo();
11
by: mdh | last post by:
Well, K& R has finally gotten to header files!!! May I ask this. (Have checked out the FAQ) I am using "Xcode" to compile the program, so it may well be that this is doing something strange. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.