how to find current working user
Tim Chase
python.list at tim.thechases.com
Mon Feb 11 14:36:24 EST 2008
More information about the Python-list mailing list
Mon Feb 11 14:36:24 EST 2008
- Previous message (by thread): how to find current working user
- Next message (by thread): Help with jabber client in wx
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> Can anyone tell me how to find current working user in windows?
The below should be fairly cross-platform:
>>> import getpass
>>> whoami = getpass.getuser()
>>> print whoami
W: tchase
L: tim
("W:" is the result on my windows box, "L:" is the result on my
Linux box) which can be used in concert with
>>> import user
>>> print user.home
W: C:\Documents and Settings\tchase
L: /home/tim
or
>>> import os
>>> os.expanduser('~/Desktop')
W: C:\Documents and Settings\tchase/Desktop
L: /home/tim/Desktop
in case you need either of them.
-tkc
- Previous message (by thread): how to find current working user
- Next message (by thread): Help with jabber client in wx
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list