Re: PATH environment variable
Fredrik Lundh wrote: > what part of your observations makes you think that the environment isn't > "captured" (i.e. > copied from the process environment) when the os module is > imported ? Answer: the part that was informed by a fundamental misunderstanding on my part of how the os module obtains information. Based on Mr. Lundh's 'copied from the process environment' remark and his hint, I would infer the following: 1) In the observations I detailed, the 'process' is the pythonwin application 2) When the pythonwin application is invoked, it obtains a copy of the current environment 3) the import os statement obtains information from the copy of the current environment that was obtained when the pythonwin process began 4) a reload(os) or a combination of del os followed by import os also get information from the copy of the current environment that was obtained when the pythonwin process began My questions: a) are the above inferences (albeit oversimplified) correct? b) when the hint refers to a new process, does the term 'process' refer to the same concept that is described in secion 6.1.5 of the Python Library Reference? -- http://mail.python.org/mailman/listinfo/python-list
Re: PATH environment variable
[EMAIL PROTECTED] wrote: > Do these observations fit with what is stated in section 6.1.1 of the > Python Library Reference? yes. what part of your observations makes you think that the environment isn't "captured" (i.e. copied from the process environ- ment) when the os module is imported ? (hint: when you start a new process, it gets a *copy* of the current environment. changes to the original won't affect this copy. all modern operating systems work the same way). -- http://mail.python.org/mailman/listinfo/python-list
Re: PATH environment variable
I observed something tangential to this topic, and that is the reason for this reply. I don't understand when os.environ gets updated. The '...captured the first time the os mdule is imported...' verbiage from the following link: http://www.python.org/dev/doc/newstyle/lib/os-procinfo.html provides some information, but it's not clear how to make that fit with the following observations: Sequence of steps...observation 1: 1) open Pythonwin interactive window 2) import os 3) os.environ['PATH'] - this presents the contents of the PATH variable 4) using Windows system properties/environment variables, change contents of PATH variable; apply the changes (after closing, I got back in to verify that the PATH variable was, in fact, changed) 5) in interactive window, reload(os) 6) os.environ['PATH'] - presents same value is in #3 Sequence of steps...observation 2: 1) open Pythonwin interactive window 2) import os 3) os.environ['PATH'] - this presents the contents of the PATH variable 4) using Windows system properties/environment variables, change contents of PATH variable; apply the changes (after closing, I got back in to verify that the PATH variable was, in fact, changed) 5) in interactive window, del os 6) in interactive window, import os 7) os.environ['PATH'] - presents the same value as in #3 I also observed that if I exit the interactive window, and then go back into the interactive window, the os.environ['PATH'] reflects changes to the PATH environment variable that happened while in the interactive window the first time. Do these observations fit with what is stated in section 6.1.1 of the Python Library Reference? -- http://mail.python.org/mailman/listinfo/python-list
Re: PATH environment variable
[EMAIL PROTECTED] wrote: > O/S: Win2K > Vsn of Python:2.4 > > Based on a search of other posts in this group, it appears as though > os.environ['PATH'] is one way to obtain the PATH environment variable. > > My questions: > 1) is it correct that os.environ['PATH'] contains the PATH environment > variable? > 2) are there other ways to obtain the PATH environment variable? if so, > is one way of obtaining the PATH environment variable preferable to > another way? > That's the best way because it's portable. If you didn't have os.environ, you might be able to get PATH but reading the output of some subprocess, e.g: import commands path = commands.getoutput('echo $PATH') -- http://mail.python.org/mailman/listinfo/python-list
Re: PATH environment variable
[EMAIL PROTECTED] wrote: > Based on a search of other posts in this group, it appears as though > os.environ['PATH'] is one way to obtain the PATH environment variable. > > My questions: > 1) is it correct that os.environ['PATH'] contains the PATH environment > variable? yes. > 2) are there other ways to obtain the PATH environment variable? if so, > is one way of obtaining the PATH environment variable preferable to > another way? no. using the environ variable is the preferred way to read environment variables. -- http://mail.python.org/mailman/listinfo/python-list
PATH environment variable
O/S: Win2K Vsn of Python:2.4 Based on a search of other posts in this group, it appears as though os.environ['PATH'] is one way to obtain the PATH environment variable. My questions: 1) is it correct that os.environ['PATH'] contains the PATH environment variable? 2) are there other ways to obtain the PATH environment variable? if so, is one way of obtaining the PATH environment variable preferable to another way? -- http://mail.python.org/mailman/listinfo/python-list