Getting the Appdata Directory with Python and PEP?

Mark Lawrence breamoreboy at yahoo.co.uk
Wed Nov 27 00:21:28 CET 2013


On 26/11/2013 22:49, Eamonn Rea wrote:
> 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 :)
>

Do you realise that stock markets wordwide have plumetted again today 
because of the massive surplus of newlines from this year's harvests? 
The only way to get the markets back up, and with it my pension funds, 
is to invest very heavily in a tool that somehow prevents this surplus. 
  Would you be kind enough to get one?

-- 
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence




More information about the Python-list mailing list