Working with environment variables.

aditya shukla adityashukla1983 at gmail.com
Thu Sep 11 02:39:53 CEST 2008


Hello folks, i am working with Python-2.5.2, fedora 9 sulphur

I wanna change the value of environment variable , so if i open bash and
type


envvariable=value;export variable then this sets the envvariable equal to
the value.Now i am writing a python script to set  the value of this
environment variable.

import optparse
import os

def new_callback(option, opt_str, value, parser):

       os.putenv("envvariable",value)

if __name__ == '__main__':

     p = optparse.OptionParser()

     p.add_option('-H',action="callback",callback=new_callback,type
="string")

     options, remainder = p.parse_args()


when i run the script python prog.h -H value


now this dosen't change the value of the  variable which was set earlier
.Please help me in fixing this issue.


Thanks in advance

Aditya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080910/2b1c6718/attachment.html>


More information about the Python-list mailing list