Getting the Appdata Directory with Python and PEP?

Eamonn Rea eamonnrea at gmail.com
Tue Nov 26 23:49:09 CET 2013


On Tuesday, November 26, 2013 7:40:50 PM UTC, Irmen de Jong wrote:
> 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

I saw this, but I wanted to do it myself as I stated in the OP :)



More information about the Python-list mailing list