473,549 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ 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 3738
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\Li b\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\Li b\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
12903
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 otherwise. Most interesting to me is that a reboot won't fix the problem. But if I just try it again sometime later it will work. Anyone have any ideas? ...
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 environment variable points to C:
4
2249
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 this? Cheers
15
7369
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 history command in IDLE (in fact with IDLE in general). Often I'll develop new code at the command line, testing each line as I go. Currently I have...
13
2800
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 UE to run external tools, but I can't figure out how to run IDLE this way, because when I check on its properties to find it's file path, it is...
0
1179
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, 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...
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, 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...
3
2443
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 subprocess didn't make connection. ... firewall may be blocking the connection." I doubt the FW connection. There's a small X warning dialog that...
3
2882
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
7461
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...
0
7730
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7971
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7491
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...
0
6055
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5381
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...
1
1956
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
1
1068
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
776
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.