On Wed, Jan 25, 2017 at 11:04 AM, Thomas Kluyver <tho...@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. > > Thomas > > Right, that is why we would have three properties 1. suffix: gets the part after the last period as a string, including the period (already exists), so "spam.tar.gz" -> ".gz" 2. fullsuffix: gets the part after the first period as a string, including the period (this is what I am proposing), so "spam.tar.gz" -> ".gz" 3. suffixes: gets the part after the first period as a list of strings split on the leading period, each including the leading period (already exists), so "spam.tar.gz" -> [".tar", ".gz"] "suffix" is only useful if you are sure only the part after the last period is useful, "fullsuffix" is only useful if you are sure the entire part after first period is useful, and "suffixes" is needed in more complicated situations. This is similar in principle to having "str.split", "str.rsplit", "str.partition", and "str.rpartition". pathlib currently has the equivalent of "str.split" (suffixes) and "str.rpartition" (suffix), but lacks the equivalent of "str.partition" (fullsuffix).
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/