On Mon, 7 May 2018 at 08:17 Serhiy Storchaka <storchaka@gmail.com> wrote:
07.05.18 17:42, Eric Snow пише:
> I'm not necessarily saying we should add ModuleSpec.dirname(), but it
> (or something like it) is what I'd advocate for *if* we were to add a
> convenient shortcut to the directory a module is in.  FWIW, I'd
> probably use it.

The question is *why* you need the absolute path to the directory the
module is in? Taking into account the availability of
importlib.resources etc.

And just "why", and "how often"? I'm sure we have all done it before, but it isn't something that comes up constantly. And duplicating part of the details what __spec__.location contains just to save an import and a line to strip off the file seems unnecessary. Plus, this doesn't take into consideration the fact that not every module is going to exist in a directory (e.g. what if I loaded from a sqlite database?).

IOW I'm -1 on this addition to modules as I don't think it's difficult enough or used enough to warrant adding the overhead of providing it.