Home  >  Magazine  >  #73 May 2000  >  Python Programming for Beginners  >  Listing 17. Modifying an Environment Variable
Wednesday, March 29, 2000 | Last Updated 03:43:28 PM


  

Listing 17. Modifying an Environment Variable

#! /usr/local/bin/python
import os
if os.environ['USER']:
    print 'USER was '+os.environ['USER']
    old_user = os.environ['USER']
    os.environ['USER'] = 'Jacek''
    print 'USER is now '+os.environ['USER']
    os.environ['USER'] = old_user
    print 'USER is '+os.environ['USER']+' back again.'