473,486 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

IDLE Python and Environment Variables

Hello community:
I post this because I could not find satisfactory answers in the posts
generated by this nice group.
I work on winXP. I have many little python applications in different
folders, each application can share or not other objects located in the

same or other folders.
The way I work to use these applications is:
1) For almost everyone, I execute a corresponding ".bat file" into

which I define and/or include values for some "temporal"
environment variables that let me find all the objects that the
selected application uses. Sometimes I include in the .bat file the
execution of the application, but generally I leave in a prompt status,

ready to invoke python or some dos commands.
2) When I close the command prompt window, there are no traces of
my
enviroment variables in my windows system (that is right). Only the
default windows environment variables remain.

I tried to do the same with the IDLE (and I imagine tha same occurs
with Python command line), but I have the next problem:
I can not find in IDLE (or another app?) the way to previously define
and/or include automatically values for my "temporal" environment
variables as I do in the .bat files. The use of Control Panel -System

-Advanced is tedious to use as, my enviroment variables values are
"temporal".
Any advice, please???

Jan 11 '07 #1
3 3726
At Wednesday 10/1/2007 23:24, Tristan wrote:
>1) For almost everyone, I execute a corresponding ".bat file" into

which I define and/or include values for some "temporal"
environment variables that let me find all the objects that the
selected application uses. Sometimes I include in the .bat file the
execution of the application, but generally I leave in a prompt status,

ready to invoke python or some dos commands.
What kind of environment variables? Those used by Python itself, like
PYTHONPATH? Or your own variables, like FOO_LOCATION=C:\My\Projects\Lib\Foo
>2) When I close the command prompt window, there are no traces of
my
enviroment variables in my windows system (that is right). Only the
default windows environment variables remain.

I tried to do the same with the IDLE (and I imagine tha same occurs
with Python command line), but I have the next problem:
I can not find in IDLE (or another app?) the way to previously define
and/or include automatically values for my "temporal" environment
variables as I do in the .bat files.
So you write a .bat that:
- defines some variables
- calls your script.
It appears that your variables are some kind of configuration - in
this case it has more sense to put such configuration in another
place, like a config file, and forget about environment variables.
You can use the usual .ini Windows format and read it with
ConfigParser. You can pass your script the name of the ini file to
read - this would be the equivalent of using different .bat files to
call the same script.
This way it doesn't matter whether you invoke your application using
python command line, or inside IDLE, or inside another environment.
--
Gabriel Genellina
Softlab SRL


__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

Jan 11 '07 #2
Thanks Gabriel.
What kind of environment variables? Those used by Python itself, like
PYTHONPATH? Or your own variables, like FOO_LOCATION=C:\My\Projects\Lib\Foo
I need to add to PYTHONPATH and other enviroment variables asked, for
example, by DJANGO or other python products.
It appears that your variables are some kind of configuration - in
this case it has more sense to put such configuration in another
place, like a config file, and forget about environment variables.
You can use the usual .ini Windows format and read it with
ConfigParser. You can pass your script the name of the ini file to
read - this would be the equivalent of using different .bat files to
call the same script.
This way it doesn't matter whether you invoke your application using
python command line, or inside IDLE, or inside another environment.
I considered to use it, thanks!! Incidentally (beg your pardon if it
sounds to ignorance), can I define Environment variables in a config
file and then apply to my python program?

Thanks!!!

Jan 11 '07 #3
At Thursday 11/1/2007 11:45, Tristan wrote:
>I considered to use it, thanks!! Incidentally (beg your pardon if it
sounds to ignorance), can I define Environment variables in a config
file and then apply to my python program?
Yes, read them from the config file and then use os.environ['name']=value
See http://docs.python.org/lib/os-procinfo.html
--
Gabriel Genellina
Softlab SRL


__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

Jan 11 '07 #4

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

Similar topics

16
12896
by: Kerry Neilson | last post by:
For the past couple of months, Idle won't start when I invoke it. I am at a complete loss for why this is. When this happens, they python command line still starts, and python works fine...
1
1657
by: tony.ha | last post by:
Hello, I have a question about Python IDLE, when I run a Python script under the Edit Window of IDLE, i.e Run -> Run Module, I have the following Message: IDLE 1.0.3 >>> Warning: HOME...
4
2245
by: Sven Erik Knop | last post by:
Hi probably an old problem, but maybe you can help me: Just installed Python 2.3.4 on Windows XP SP1, and although the interpreter runs fine, IDLE will not start. Any ideas how to solve...
15
7354
by: Ashot | last post by:
This is sort of both Python and Vim related (which is why I've posted to both newsgroups). Python related: ---------------------- I have been frustrated for quite some time with a lack of a...
13
2791
by: John Salerno | last post by:
If I want to write my code in a separate text editor (I like UltraEdit) but then press a single button to have that code run in the IDLE environment, is that possible? I know that you can configure...
0
1178
by: Tristan | last post by:
Hello community: I post this because I could not find satisfactory answers in the posts generated by this nice group. I work on winXP. I have many little python applications in different folders,...
0
236
by: Tristan | last post by:
Hello community: I post this because I could not find satisfactory answers in the posts generated by this nice group. I work on winXP. I have many little python applications in different folders,...
3
2436
by: W. Watson | last post by:
After simply trying to write a program with help(MakeQTE), a module, and having it fail with socket errors, I decided to restart IDLE, thinking I knew the cause. I'm now getting msgs like: "IDLE's...
3
2881
by: Giraffe | last post by:
I have the followong class in a file: -------------------------------------------- class someClass: def __init__ (self): self.someVar = 10 def getSomeVar (self): return self.someVar...
0
7123
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,...
1
6839
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
7305
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
5427
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,...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
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 ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.