Skip to main content
Formatting.
Source Link
Mateen Ulhaq
  • 27.9k
  • 21
  • 121
  • 155

If you are needing this to get user's home dir, below could be considered as portable (win32 and linux at least), part of a standard library.

>>> os.path.expanduser('~') 'C:\\Documents and Settings\\johnsmith' 

Also you could parse such string to get only last path component (ie. user name).

See: os.path.expanduseros.path.expanduser

If you are needing this to get user's home dir, below could be considered as portable (win32 and linux at least), part of a standard library.

>>> os.path.expanduser('~') 'C:\\Documents and Settings\\johnsmith' 

Also you could parse such string to get only last path component (ie. user name).

See: os.path.expanduser

If you are needing this to get user's home dir, below could be considered as portable (win32 and linux at least), part of a standard library.

>>> os.path.expanduser('~') 'C:\\Documents and Settings\\johnsmith' 

Also you could parse such string to get only last path component (ie. user name).

See: os.path.expanduser

If you are needing this to get user's home dir, below could be considered as portable (win32 and linux at least), part of a standard library.

>>> os.path.expanduser('~') 'C:\\Documents and Settings\\johnsmith' 

Also you could parse such string to get only last path component (ie. user name). See

See: http://docs.python.org/2/library/os.path.html#os.path.expanduser

If you are needing this to get user's home dir, below could be considered as portable (win32 and linux at least), part of a standard library.

>>> os.path.expanduser('~') 'C:\\Documents and Settings\\johnsmith' 

Also you could parse such string to get only last path component (ie. user name). See: http://docs.python.org/2/library/os.path.html#os.path.expanduser

If you are needing this to get user's home dir, below could be considered as portable (win32 and linux at least), part of a standard library.

>>> os.path.expanduser('~') 'C:\\Documents and Settings\\johnsmith' 

Also you could parse such string to get only last path component (ie. user name).

See: os.path.expanduser

Source Link
HezniK
  • 301
  • 3
  • 2

If you are needing this to get user's home dir, below could be considered as portable (win32 and linux at least), part of a standard library.

>>> os.path.expanduser('~') 'C:\\Documents and Settings\\johnsmith' 

Also you could parse such string to get only last path component (ie. user name). See: http://docs.python.org/2/library/os.path.html#os.path.expanduser