title: Difference between os.getlogin() and os.environ for getting Username
body: <p>Is there a difference between using <code>os.getlogin()</code> and <code>os.environ</code> for getting the current user's username on Linux?</p>
  
  <p>At different times I've seen someone recommend looking at the environment variables <code>$USER</code> or <code>$LOGNAME</code>, and other times <code>os.getlogin()</code> was recommended.</p>
  
  <p>So I'm curious: is one preferred, or are there situations where you would use one over the other, or are they simply two ways of doing the same thing?</p>