[Python-ideas] Add appdirs module to stdlib
p.f.moore at gmail.com
Wed Sep 2 01:05:20 CEST 2015
On 1 September 2015 at 22:47, Andrew Barnert via Python-ideas
<python-ideas at python.org> wrote:
> Things like app data and prefs aren't a single directory. XDG has a notion of a search path rather than a single directory; Windows has a notion of separate search domains; OS X makes things as fun as possible by having both. For writing a new file, you're usually fine just writing to the first path in the default domain (as long as it exists or you can create it), but for reading files you're supposed to look in /etc or All Users or whatever if it's not found there. Most cross-platform wrappers I've used in the past didn't deal with this automatically, and a lot of them didn't even make it easy to do manually.
This is a fair point. But it's also worth noting that the current
state of affairs for many apps is to just bung stuff in ~/whatever.
While appdirs may not get things totally right, at least it improves
things. And if it (or something similar) were in the stdlib, it would
at least provide a level of uniformity.
So, in my view:
1. We should have something that provides the functionality of appdirs
in the stdlib.
2. It probably needs a PEP to get the corner cases right.
3. The behaviour of appdirs is a good baseline default - even if it
isn't 100% compliant with platform standards it'll be better than what
someone unfamiliar with the platform will invent.
4. We shouldn't abandon the idea just because a perfect solution is
There are complex cases to consider (search paths, for example, and
even worse how search paths interact with the app writing config data
rather than just reading it, or migration when a scheme changes). The
PEP should at least mention these cases, but it's not unreasonable to
simply declare them out of scope of the module (most applications
don't need anything this complex).
More information about the Python-ideas