title: whoami in python
body: <p>What is the best way to find out the user that a python process is running under?</p>
  
  <p>I could do this:</p>
  
  <pre><code>name = os.popen('whoami').read() 
  </code></pre>
  
  <p>But that has to start a whole new process.</p>
  
  <pre><code>os.environ["USER"]
  </code></pre>
  
  <p>works sometimes, but sometimes that environment variable isn't set.</p>