getting the current userid with Python

Matt Gerrans matt_gerrans at hp.com
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('WScript.network')
>>> net.Username
u'Monty'





More information about the Python-list mailing list