Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60454
| Path | csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <robotsondrugs@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'cpython': 0.05; 'explicitly': 0.05; 'subject:Python': 0.06; 'detect': 0.07; 'problem?': 0.07; 'subject:Getting': 0.07; 'subject:PEP': 0.07; 'string': 0.09; 'try:': 0.09; 'vista': 0.14; 'windows': 0.15; '(completely': 0.16; 'os;': 0.16; 'storing': 0.16; 'way;': 0.16; 'wrote:': 0.18; 'library': 0.18; 'example': 0.22; 'header:User-Agent:1': 0.23; 'directory.': 0.24; 'exists': 0.24; 'fine': 0.24; 'environment': 0.24; "i've": 0.25; 'header:In- Reply-To:1': 0.27; 'idea': 0.28; 'received:10.0.0': 0.31; "skip:' 10": 0.31; 'keyerror:': 0.31; 'os,': 0.31; 'allows': 0.31; 'subject:the': 0.34; "i'd": 0.34; 'could': 0.34; 'problem': 0.35; 'subject:with': 0.35; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'doing': 0.36; "didn't": 0.36; 'subject:?': 0.36; 'received:10.0': 0.36; 'received:10': 0.37; 'skip:o 20': 0.38; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'heard': 0.39; 'to:addr:python.org': 0.39; 'users': 0.40; 'how': 0.40; 'even': 0.60; 'skip:u 10': 0.60; 'skip:o 30': 0.61; 'such': 0.63; 'here': 0.66; 'experience.': 0.67; 'home': 0.69; 'freebsd': 0.84; 'good,': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=7z5lhdxTafXIh4kKDBFrb+YP3Zza0k39+s6O9JEgJBU=; b=hKRFA7Ev5e6mEF9SW1k9QCKILjUpnGMDX4pCxhl7jW1ej/17A/VlgSYEbEpykkrWWc uj1jTY40oY3MM5awyQBymJGcFX8SwmN/U/GDsrZeA5nrJlXVqe/73V22ZKfE2wQ4Seqq 8v6qd2dFFxH1tm+M7XbxzU4b/Idt6xoKK8p3TgDZGYp+m/i3m0+i3vZgxuxQY2sjePef 4gSpt2bDfnTcaRrM5sZ9RSfCXNFiHfrX/S+2guvFKzBrMzLPAt51LDcc4Q3aOTPboLeJ y3UhaCQBbX0YZI2qUzInQ0jZ0wzO2p48uT5k6/YgJqAgs8y/xjm7Rd0SF5nP0roHCLWo EaAA== |
| X-Received | by 10.42.24.138 with SMTP id w10mr18023415icb.22.1385413846692; Mon, 25 Nov 2013 13:10:46 -0800 (PST) |
| Date | Mon, 25 Nov 2013 15:10:47 -0600 |
| From | Andrew Berg <robotsondrugs@gmail.com> |
| User-Agent | Mozilla/5.0 (Windows NT 6.2; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Getting the Appdata Directory with Python and PEP? |
| References | <50402350-c9cb-47be-b513-ad2fb7170187@googlegroups.com> |
| In-Reply-To | <50402350-c9cb-47be-b513-ad2fb7170187@googlegroups.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3195.1385413849.18130.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1385413849 news.xs4all.nl 15863 [2001:888:2000:d::a6]:42816 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:60454 |
Show key headers only | View raw
On 2013.11.25 14:48, Eamonn Rea wrote:
> I've heard that there is a library that allows you to get the appdata directory for a given OS, but I'd like to do it myself, as a learning experience.
>
> Is there a built in way to get a users Appdata Directory? For example on OS X it's in '~/Library//Application Support/'. I can get the OS just fine (sys.platform and then storing it in my own way; example: darwin = OS X, just for my own readability), and I can get the home directory just fine (expanduser), but I have no idea how to get the appdata directory.
>
> One way I could think of doing it would be to just detect the os and join the string on like so (completely untested, but an idea);
>
> if os == 'OS X':
> appdata_dir = os.path.join(home_dir, '/Application Support/')
>
> But then that arises the problem of cross platform compatibility.
>
> So is here a good, cross platform solution to this problem?
I don't know about OS X, but on Windows Vista and later, there is os.environ['APPDATA']. I don't explicitly check for OS; instead, I see if
APPDATA exists as an environment variable:
try:
user_data_dir = os.path.join(os.environ['APPDATA'], 'NoiseBot')
except KeyError:
user_data_dir = os.path.join(os.environ['HOME'], '.NoiseBot')
I didn't even know that such a thing existed on OS X.
--
CPython 3.3.2 | Windows NT 6.2.9200 / FreeBSD 10.0
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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