Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60534

Re: Getting the Appdata Directory with Python and PEP?

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Getting the Appdata Directory with Python and PEP?
Date 2013-11-26 13:52 -0500
Organization IISS Elusive Unicorn
References <50402350-c9cb-47be-b513-ad2fb7170187@googlegroups.com> <27870dae-87ff-4435-a2ff-a42f95c21d48@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.3253.1385491930.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, 26 Nov 2013 10:09:11 -0800 (PST), Eamonn Rea <eamonnrea@gmail.com>
declaimed the following:

>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.
>

	APPDATA is a Windows conceit...

	My impression is that UNIX/Linux relies upon dot-directories
(file/directory names beginning with a . being automatically hidden).

~/.myAppData

and ~ expanding to the login home directory...



	Note that my Windows system doesn't /have/ a HOME variable


C:\Users\Wulfraed\Documents>set appdata
APPDATA=C:\Users\Wulfraed\AppData\Roaming

C:\Users\Wulfraed\Documents>set home
HOMEDRIVE=C:
HOMEPATH=\Users\Wulfraed

C:\Users\Wulfraed\Documents>set userprofile
USERPROFILE=C:\Users\Wulfraed

C:\Users\Wulfraed\Documents>

The closest is USERPROFILE (which is initially %HOMEDRIVE%%HOMEPATH%)

C:\Users\Wulfraed\Documents>echo %userprofile%
C:\Users\Wulfraed

C:\Users\Wulfraed\Documents>echo %homedrive%%homepath%
C:\Users\Wulfraed


PowerShell, OTOH

PS C:\Users\Wulfraed\Documents> Get-Variable home

Name                           Value
----                           -----
HOME                           C:\Users\Wulfraed
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Getting the Appdata Directory with Python and PEP? Eamonn Rea <eamonnrea@gmail.com> - 2013-11-25 12:48 -0800
  Re: Getting the Appdata Directory with Python and PEP? Andrew Berg <robotsondrugs@gmail.com> - 2013-11-25 15:10 -0600
  Re: Getting the Appdata Directory with Python and PEP? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-25 21:20 +0000
  Re: Getting the Appdata Directory with Python and PEP? Eamonn Rea <eamonnrea@gmail.com> - 2013-11-26 10:09 -0800
    Re: Getting the Appdata Directory with Python and PEP? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-26 13:52 -0500
    Re: Getting the Appdata Directory with Python and PEP? Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2013-11-26 20:40 +0100
      Re: Getting the Appdata Directory with Python and PEP? Eamonn Rea <eamonnrea@gmail.com> - 2013-11-26 14:49 -0800
        Re: Getting the Appdata Directory with Python and PEP? Chris Angelico <rosuav@gmail.com> - 2013-11-27 10:20 +1100
          Re: Getting the Appdata Directory with Python and PEP? Eamonn Rea <eamonnrea@gmail.com> - 2013-11-28 08:11 -0800
            Re: Getting the Appdata Directory with Python and PEP? Chris Angelico <rosuav@gmail.com> - 2013-11-29 04:28 +1100
            Re: Getting the Appdata Directory with Python and PEP? rusi <rustompmody@gmail.com> - 2013-11-28 10:32 -0800
            Re: Getting the Appdata Directory with Python and PEP? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-28 16:29 -0500
        Re: Getting the Appdata Directory with Python and PEP? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-26 23:21 +0000
        Re: Getting the Appdata Directory with Python and PEP? Kevin Walzer <kw@codebykevin.com> - 2013-12-02 09:39 -0500

csiph-web