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

Command-line option equiv of PYTHONPATH

Hi,

The '-I<path>' option adds the path to the list of directories that
contains modules that can be included in a script. I can use it as "#!/
usr/bin/perl -I<path_to_my_modules>" thereby not asking the user of
the script to set the <path_to_my_modulesin their environment.

Is there any equivalent command-line option to the python binary or a
command-line version of PYTHONPATH?

Regards
Rajesh

Apr 27 '07 #1
5 3378
Rajesh wrote:
Hi,

The '-I<path>' option adds the path to the list of directories that
contains modules that can be included in a script. I can use it as "#!/
usr/bin/perl -I<path_to_my_modules>" thereby not asking the user of
the script to set the <path_to_my_modulesin their environment.

Is there any equivalent command-line option to the python binary or a
command-line version of PYTHONPATH?

Regards
Rajesh
Why not just modify sys.path within the actual script?

James
Apr 27 '07 #2
The '-I<path>' option adds the path to the list of directories that
contains modules that can be included in a script. I can use it as "#!/
usr/bin/perl -I<path_to_my_modules>" thereby not asking the user of
the script to set the <path_to_my_modulesin their environment.

Is there any equivalent command-line option to the python binary or a
command-line version of PYTHONPATH?
To rephrase James Stroud's remark: The equivalent to

#/usr/bin/perl -I<path_to_my_modules>
TEXT

is

#/usr/bin/python
import sys
sys.path.append(path_to_my_modules)
TEXT

HTH,
Martin
Apr 27 '07 #3
On 2007-04-27, James Stroud <js*****@mbi.ucla.eduwrote:
Rajesh wrote:
>Hi,

The '-I<path>' option adds the path to the list of directories that
contains modules that can be included in a script. I can use it as "#!/
usr/bin/perl -I<path_to_my_modules>" thereby not asking the user of
the script to set the <path_to_my_modulesin their environment.

Is there any equivalent command-line option to the python binary or a
command-line version of PYTHONPATH?

Regards
Rajesh

Why not just modify sys.path within the actual script?
Maybe because he has multiple versions of modules he wants to test his
script against.

--
Antoon Pardon
Apr 27 '07 #4
Antoon Pardon <ap*****@forel.vub.ac.bewrites:
On 2007-04-27, James Stroud <js*****@mbi.ucla.eduwrote:
Rajesh wrote:
Hi,

The '-I<path>' option adds the path to the list of directories that
contains modules that can be included in a script. I can use it as "#!/
usr/bin/perl -I<path_to_my_modules>" thereby not asking the user of
the script to set the <path_to_my_modulesin their environment.

Is there any equivalent command-line option to the python binary or a
command-line version of PYTHONPATH?

Regards
Rajesh
Why not just modify sys.path within the actual script?

Maybe because he has multiple versions of modules he wants to test his
script against.

--
Antoon Pardon

Here are some approaches we've used:

1. Write a small script which sets PYTHONPATH and then calls the app.
Make a different script for each setup you need.

2. Use a small script to set a couple of envvars, which in turn are
used to find the right config file, which has all the config
decisions you want.

archtool_path= os.getenv('ARCHTOOL_PATH')
archtool_cfg = os.getenv('ARCHTOOL_CFG')
sys.path.insert(0,archtool_path)
import archtool
exec "import archtool.%s as cfg" % archtool_cfg
--
Harry George
PLM Engineering Architecture
Apr 27 '07 #5
>Why not just modify sys.path within the actual script?

Maybe because he has multiple versions of modules he wants to test his
script against.
See the original post: 'I can use it as "#!/usr/bin/perl
-I<path_to_my_modules>"' so clearly his intention is modify
the script.

Martin
Apr 27 '07 #6

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

Similar topics

1
by: TEK | last post by:
Hello I'm wondering if anyone out there might give some input/suggestions/viewpoints around the Command pattern. In my case, the number one priority for using the pattern is undo support. Some...
8
by: Siemel Naran | last post by:
Hi. I'm writing a command shell that reads commands from standard input. At this point I have the command in a std::string. Now I want to execute this command in the shell. From the Borland...
2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
8
by: Charles Law | last post by:
I am implementing the command pattern in VB.NET, where the commands have been serialised. That is, I have several classes that all inherit from my base Command class, that implements ICommand...
2
by: micahstrasser | last post by:
I have been trying for days to send a command to the command prompt through the shell() function in vb.net. For some reason it is not working. Here is the code: Private Sub Button1_Click(ByVal...
4
by: FluffyCat | last post by:
New on November 29, 2005 for www.FluffyCat.com PHP 5 Design Pattern Examples - the Command Pattern. Since you all enjoyed the Visitor Pattern so much yesterday, today I have the Command Pattern...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
0
by: czerwww | last post by:
Can someone please help me? I have class for database connection and I need set command.commandTimeout. How can I do that? Code: Imports System.Data.SqlClient Imports System.Data Public Class...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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.