Sending mail from 'current user' in Python
Irmen de Jong
irmen.NOSPAM at xs4all.nl
Sat Jun 11 09:58:26 EDT 2005
Grig Gheorghiu wrote:
> I use this function as a platform-independent way of finding out the
> current user name:
>
> def get_username():
> if sys.platform == 'win32':
> return win32api.GetUserName()
> else:
> return getpass.getuser()
>
[e:\]python
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import getpass
>>> getpass.getuser()
'idj'
So why bother with the win32api??
--Irmen
More information about the Python-list
mailing list