return to first page linux journal archive
keywordscontents

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.'