getting the current userid with Python

Matt Gerrans matt_gerrans at
Wed Aug 21 16:26:39 EDT 2002

Yes, getpass.getuser() seems to work fine on XP, too.

If it doesn't work on another version of Windows, this might do the trick:

>>> from win32com import Dispatch
>>> net = Dispatch('')
>>> net.Username

More information about the Python-list mailing list