tags:

views:

54

answers:

1

I need to get the location of the home directory of the current logged-on user. Currently, I've been using the following on Linux:

os.getenv("HOME")

However, this does not work on Windows. What is the correct cross-platform way to do this?

+4  A: 

You want to use os.path.expanduser. This will ensure it works on all platforms

dcolish
As in from os.path import expanduser home = expanduser("~")
lazy1
Yup, that's right. Sorry I didn't include an example.
dcolish