[Python-ideas] pathlib suggestions
Chris Angelico
rosuav at gmail.com
Tue Jan 24 16:27:59 EST 2017
On Wed, Jan 25, 2017 at 7:30 AM, Todd <toddrjen at gmail.com> wrote:
> First, for me, extensions are primarily useful as a single unit. So,
> practically speaking, the extension of "spam.tar.gz" isn't ".gz", it is
> ".tar.gz". So it would be nice to have some properties to make it easier to
> deal with the "complete" extension like this. There is a "suffixes"
> property, but it returns a list, which you then have to recombine manually.
> And as far as I can tell there is no method to return the name without any
> extension. And there is no method for replacing all the extensions at once.
>
> So although the names are tentative, perhaps there could be a "fullsuffix"
> property to return the extensions as a single string, a "nosuffix" extension
> to return the path without any extensions, and a "with_suffixes" method that
> replaces all the suffix and can accept multiple arguments (which would then
> be joined to create the extensions).
+0. Not all files with multiple dots in them are actually using them
to mean multiple file extensions. Every day I'm working with files
that use dots to separate words in a title, or have section numbers
("4.2.5 Yada Yada Yada.md" does not have a base name of "4"), etc.
Since there's no perfect way to pin these down, this needs to be a
completely separate feature, and it'd only really be useful for some
situations. So go ahead, if there's interest, but the current one
shouldn't be deprecated or anything.
ChrisA
More information about the Python-ideas
mailing list