detecting the operating system

Josiah Carlson jcarlson at nospam.uci.edu
Sun Feb 29 15:21:54 EST 2004


>>Checking sys.platform is easy enough. I use it to figure out if I'm
>>running on Linux or Windows. For Linux I take the users home directory
>>to put files in. In Windows I check the registry to find out the
>>location of My Documents and then save files there.
> 
> 
> os.path.expanduser("~") ?

Doesn't work for all platforms.  Occasionally in windows that will 
expand to %USERPROFILE%, which you then have to resolve with os.getenv.

  - Josiah



More information about the Python-list mailing list