Re: Applications user/system directories functions

On Wed, Dec 15, 2021 at 4:29 PM Christopher Barker <pythonchb@gmail.com> wrote:
I agree -- I've wanted something like that for years in the stdlib. wxPython has wx.StandardPaths -- and it's really handy. But a wrapper around a C++ version, so not useful outside of wx. -CHB
-- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython

It would be a good idea to add something like appdirs to the stdlib. Maybe something like os.path.userdata() (as an example name). I have four questions: 1. What should the functions be called, and module should they go in? I personally say os.path module, with names such as userdata() for consistency with the rest of the os module. 2. Should the functions take the app name and author, or just return the base path, e.g. ~/. local/share? The latter makes more sense to me if I had to pick one, but my personal recommendation would be to make the name and author optional arguments, so userdata() returned (on Linux) ~/.local/share, but userdata(appname="foo") returned ~/.local/share/foo. This seems to be the behavior of the appdirs functions. 3. Should we include something like the AppDirs class, which is a wrapper of sorts for the functions? I personally say no, it's not necessary or important. 4. Should this also be added to pathlib? I say definitely, probably in the form of class constructors (e.g. Path.user_data()). -- Finn (Mobile) On Wed, Dec 15, 2021, 5:35 PM Christopher Barker <pythonchb@gmail.com> wrote:

On Wed, Dec 15, 2021 at 7:35 PM Finn Mason <finnjavier08@gmail.com> wrote:
4. Should this also be added to pathlib? I say definitely, probably in the
form of class constructors (e.g. Path.user_data()).
putting it in pathlib makes a lot of sense, but I wouldn't make them a bunch of Path classmethods -- why thot their own names, but would return Path objects? Despite "flat being better than nested" I kind of like a namespace for the standar paths" path.lib.standard_paths.user_data or some such. As for the names themselves -- prior art -- I think there were two packages on PyPi with some of this, if they are popular, let's use those names. Here's appdirs: https://github.com/ActiveState/appdirs pathlib.appdirs.user_data_dir() done :-) -CHB +1 for appdirs. It's a shame that more projects don't yet use it.
-- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython

It would be a good idea to add something like appdirs to the stdlib. Maybe something like os.path.userdata() (as an example name). I have four questions: 1. What should the functions be called, and module should they go in? I personally say os.path module, with names such as userdata() for consistency with the rest of the os module. 2. Should the functions take the app name and author, or just return the base path, e.g. ~/. local/share? The latter makes more sense to me if I had to pick one, but my personal recommendation would be to make the name and author optional arguments, so userdata() returned (on Linux) ~/.local/share, but userdata(appname="foo") returned ~/.local/share/foo. This seems to be the behavior of the appdirs functions. 3. Should we include something like the AppDirs class, which is a wrapper of sorts for the functions? I personally say no, it's not necessary or important. 4. Should this also be added to pathlib? I say definitely, probably in the form of class constructors (e.g. Path.user_data()). -- Finn (Mobile) On Wed, Dec 15, 2021, 5:35 PM Christopher Barker <pythonchb@gmail.com> wrote:

On Wed, Dec 15, 2021 at 7:35 PM Finn Mason <finnjavier08@gmail.com> wrote:
4. Should this also be added to pathlib? I say definitely, probably in the
form of class constructors (e.g. Path.user_data()).
putting it in pathlib makes a lot of sense, but I wouldn't make them a bunch of Path classmethods -- why thot their own names, but would return Path objects? Despite "flat being better than nested" I kind of like a namespace for the standar paths" path.lib.standard_paths.user_data or some such. As for the names themselves -- prior art -- I think there were two packages on PyPi with some of this, if they are popular, let's use those names. Here's appdirs: https://github.com/ActiveState/appdirs pathlib.appdirs.user_data_dir() done :-) -CHB +1 for appdirs. It's a shame that more projects don't yet use it.
-- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
participants (2)
-
Christopher Barker
-
Finn Mason