James Stroud <[EMAIL PROTECTED]> wrote:
>stephen_b wrote:
>
>> Can someone let me know why this won't work? Thanks.
>> 
>>>>>from os import popen
>>>>>popen('export asdfasdf=hello').read()
>> ''
>>>>>popen('echo $asdfasdf').read()
>> '\n'
>
>Python starts a new shell for each command, so your environment variable 
>is lost. You probably want this, which makes the variable "permanent".
>
>py> import os
>py> os.environ['asdfasdf'] = 'hello'
>py> os.popen('echo $asdfasdf').read()
>'hello\n'

For completeness, let us anticipate the followup question and point out
that "permanent" here means "for this process and any processes that it
spawns".  Once the Python session ends, the "asdfasdf" will be lost.
-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to