Duplicate of: Is there a portable way to get the current username in Python?
What is the best way to find out the user that a python process is running under?
I could do this:
name = os.popen('whoami').read()
But that has to start a whole new process.
os.environ["USER"]
works sometimes, but sometimes that environment variable isn't set.