getting the current userid with Python

Danathar dougb at attglobal.net
Wed Aug 21 13:38:23 EDT 2002


Is there a direct method for getting the current userid in Python? I
am learning Python for the first time and was looking around for
methods, but the only methods that I can find in usenet usually call
external commands with the commands module or use the os module to get
the value of of the USER shell environment variable.

Those methods work, but I am trying to learn python, and somehow it
feels like I am cheeting by using python to call a shell command (like
whoami) that I already know. Getting the USER variable works, but what
if you are not in a UNIX envornment where the USER variable does not
exist?

I've looked through the books, but I can't find anything...

thanks for any suggestions?



More information about the Python-list mailing list