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

Python at compile - possible to add to PYTHONPATH

Hi all,

Can anyone help me out. I would like to have python automatically look
in a path for modules similar to editing the PYTHONPATH but do it at
compile time so every user doesn't have to do this..

Soo...

I want to add /foo/bar to the PYTHONPATH build so I don't have to add
it later on. Is there a way to do this?

../configure ??

../configure --help doesn't help..
Thanks

Jun 21 '06 #1
3 1430
On 21 Jun 2006 15:54:56 -0700, rh0dium <st**********@gmail.com> wrote:
Hi all,

Can anyone help me out. I would like to have python automatically look
in a path for modules similar to editing the PYTHONPATH but do it at
compile time so every user doesn't have to do this..

Soo...

I want to add /foo/bar to the PYTHONPATH build so I don't have to add
it later on. Is there a way to do this?


You don't need to recompile python. Just change sys.path before all
import statements.
Jun 21 '06 #2
rh0dium wrote:
(snip)
I want to add /foo/bar to the PYTHONPATH build so I don't have to add
it later on. Is there a way to do this?

(snip)

If i understand correctly, you want to add a directory to your
PYTHONPATH for a specific script without modifying the system PYTHONPATH
global variable ...

To import the Gazonk() class defined in /foo/bar/baz.py without adding
/foo/bar to PYTHONPATH you can try this:

###

import sys
sys.path.append('/foo/bar')

import baz
quux = baz.Gazonk()

###

hope it helped ...
Jun 21 '06 #3
Hi all,

Thanks for the response. Yeah that's what I'm currently doing but I
thought that it would be cleaner for me to append my own location at
compile time. I'm surprised that this doesn't exist..

Thanks.

Avell Diroll wrote:
rh0dium wrote:
(snip)
I want to add /foo/bar to the PYTHONPATH build so I don't have to add
it later on. Is there a way to do this?

(snip)

If i understand correctly, you want to add a directory to your
PYTHONPATH for a specific script without modifying the system PYTHONPATH
global variable ...

To import the Gazonk() class defined in /foo/bar/baz.py without adding
/foo/bar to PYTHONPATH you can try this:

###

import sys
sys.path.append('/foo/bar')

import baz
quux = baz.Gazonk()

###

hope it helped ...


Jun 22 '06 #4

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

Similar topics

3
by: jg.campbell.ng | last post by:
I'm beginning learning Python and OpenGL in Python. Python fine. But difficulties with OpenGL; presumably with the installation of OpenGL. OS = Linux FC5. Python program gl_test.py: from...
7
by: wardm | last post by:
I have created a Dict object in a C++ App that calls (embedded) Python functions. The Dict is to be used to pass variable data between the C++ App and the python functions. However I cannot get...
11
by: Michael Spencer | last post by:
Announcing: compiler2 --------------------- For all you bytecode enthusiasts: 'compiler2' is an alternative to the standard library 'compiler' package, with several advantages. Improved...
69
by: Edward K Ream | last post by:
The pros and cons of making 'print' a function in Python 3.x are well discussed at: http://mail.python.org/pipermail/python-dev/2005-September/056154.html Alas, it appears that the effect of...
0
by: mathieu | last post by:
Hi there, I am currently involved in managing a large python/c++ project (using swig to automagically wrap c++ code to python). So far my current experience was that python was a second class...
7
by: greg | last post by:
Thomas Philips wrote: Have a look in /Library/Frameworks/Python.framework/Versions/2.5 You can't -- this feature only exists in the Search window, which is a different kind of window...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.