I believe that running an external command with a slightly modified environment is a very common case. That\'s how I tend to do it:
import subprocess, os my_
To temporarily set an environment variable without having to copy the os.envrion object etc, I do this:
process = subprocess.Popen(['env', 'RSYNC_PASSWORD=foobar', 'rsync', \ 'rsync://username@foobar.com::'], stdout=subprocess.PIPE)