Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear os.environ value for only one variable in Python

I'm setting os.environ['PYTHONHOME']="/home/user/OpenPrint/py2.6" in my Python script

But at the end of the script I need to clear this variable so that I can call another python script from a different location. Can someone tell me how to do that? I tried os.environ.clear() but that clears all the other variables too.

like image 666
user1345260 Avatar asked Aug 12 '13 00:08

user1345260


1 Answers

Use

os.environ.pop("PYTHONHOME")

See (minimal) documentation at http://docs.python.org/2/library/os.html

like image 86
disatisfieddinosaur Avatar answered Oct 14 '22 15:10

disatisfieddinosaur