def getuser():
 import os
 for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
  user = os.environ.get(name)
  if user:
   return user
 import pwd
 return pwd.getpwuid(os.getuid())[0]

def getuser ( ) : import os for name in ( 'LOGNAME' , 'USER' , 'LNAME' , 'USERNAME' ) : user = os . environ . get ( name ) if user : return user import pwd return pwd . getpwuid ( os . getuid ( ) ) [ 0 ]
get the username from the environment or password database .