Getting the Appdata Directory with Python and PEP?
Irmen de Jong
irmen.NOSPAM at xs4all.nl
Tue Nov 26 14:40:50 EST 2013
On 26-11-2013 19:09, Eamonn Rea wrote:
> Thanks for the help on PEP, but I can't find a way to get the application support (appdata on Windows, no idea on Linux). If I do:
>
> print os.environ['HOME']
>
> I get: '/Users/eamonn', as that is my home directory. But when I do:
>
> print os.environ['APPDATA']
>
> I get an error. But when I do:
>
> print os.getenv('APPDATA')
>
> I get: None.
>
> Apparently os.getenv() works on Windows, but I can't see a way to get this on Mac. If I could get the names of this for different OS's I could just check the OS and run the appropriate code.
>
> Any help?
>
Maybe this module is of some use to you:
https://pypi.python.org/pypi/appdirs
It provides a unified Python API to the various OS specific 'user' directory locations.
Irmen
More information about the Python-list
mailing list