|
From: <bc...@wo...> - 2001-11-02 09:16:31
|
>|
>| Either os.putenv() shouldn't be implemented at all or it should be
>| implemented as:
>|
>| def putenv(varname, value):
>| os.enviroment[varname] = value
[dman]
>This depends on what the semantics of os.environ should be. In
>CPython, the line
> os.environ[ key ] = value
>doesn't work. At least, it _may_ change theh dict, but it has no
>effect on the environment.
On my win2k box it changes the environment for subsequent os.system()
calls. That is the main thing I would expect it to do:
[d:\]\python\Python211\python.exe
Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['ZZZZ'] = "new value"
>>> os.system("set")
=C:=C:\
=D:=D:\
...
windir=C:\WINNT
ZZZZ=new value
0
>>>
>| >I was thinking that, perhaps, some environment values can be gotten
>| >from Java directly. For example,
>| >
>| > print os.eviron[ "HOME" ]
>| >
>| > could be the same as
>| >
>| > System.out.println( System.getProperty( "user.home" ) ) ;
>| >
>| >though on some JVMs, user.home is really messed up (ex, jdk1.1.8 on
>| >win). I think Java ignores the user's preferences (ie setting $HOME
>| >in bash or cmd.exe) and using whatever it feels like, so this may not
>| >be a good idea.
>|
>| The property route should not be mixed with the "sh -c env" route. Using
>
>Ahh, I see, _that's_ how you get ahold of the data!
>
>| properties have been mentioned before, but nobody have picked it up and
>| suggested a patch. I guess it is because the defined set of properties
>| is too limited to be really usefull as a replacement for environment
>| variables.
>
>I am using Moshe's PMS framework with Jython right now for a school
>project. My group has not used python at all, but is familiar with
>Java hence the choice to use Jython. Anyways, in the system as it is
>shipped, there is the line
>
> DIR = os.path.join( os.environ[ "HOME" ] , "something" )
Yeah, I expect that is a common usage. Maybe we ought to have a way of
supporting it for $HOME and $USER. Maybe $CLASSPATH. Any other common
names?
regards,
finn
|