[Python-ideas] pathlib suggestions

Paul Moore p.f.moore at gmail.com
Wed Jan 25 11:10:21 EST 2017


On 25 January 2017 at 16:04, Thomas Kluyver <thomas at kluyver.me.uk> wrote:
> On Wed, Jan 25, 2017, at 03:54 PM, Todd wrote:
>
> Those [.tar.foo] are just examples that I encounter a lot, there can be
> other cases where multiple extensions are used.
>
>
> The real issue is that there's no definition of what an extension is. You
> can have dots anywhere in a filename, and it's not at all unusual for them
> to be used before the bit we recognise as the extension. Almost every
> package on PyPI has files named like 'pip-9.0.1.tar.gz', but '.0.1.tar.gz'
> clearly doesn't make any sense as an extension. Without a good definition of
> what the 'full extension' is, we can't have code to find it.

More precisely, we *can* have code to find it, but it's of necessity
application-specific, and so not a good fit for a general library like
the stdlib.

One of the design principles for code in the stdlib is "does it solve
a sufficiently general problem?" In this case, there's a general
problem, which is "give me back what I think of as the suffix in this
case" - but the proposed method doesn't solve that problem (because of
the cases already quoted). Conversely, the problem which the proposed
solution *does* solve ("give me the part of the filename after the
first dot") isn't general enough to warrant going into the stdlib,
because it's too often not what people actually want.

Paul


More information about the Python-ideas mailing list