getting the current userid with Python

brueckd at brueckd at
Wed Aug 21 20:55:41 CEST 2002

On 21 Aug 2002, Danathar wrote:

> 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?

Well, USERNAME is defined in Windows (at least some versions). ;-) 

Yeah, I know the feeling you have, but does having the user's ID on a
non-Unixish platform even mean anything? On Windows at least it's often
pretty worthless, and almost anything you can do with it is pretty
platform-specific anyway.


(hmm...that's not a very satisfying answer, huh?)

More information about the Python-list mailing list