It's ambiguous which of the two behaviors is correct in that case, but if you want to remove all extensions, you can just switch to normal split. Of course that will break if it contains a period in the name, but that's also ambiguous. I guess you need a certain level of knowledge about what you're trying to achieve.
I don't think it's ambiguous at all. It is a gzip file and so it has a `.gz` extension and your `rsplit` gets the correct result. The `.tar` is just reflecting the name of the gzipped file and not part of the extension of the current gzip file that we are currently concerned with.
I would agree for that case, but I would say one place where it does give the wrong answer (or at least, a different answer from splitext etc) is with dotfiles. Ie '.config' denotes a hidden file on unix, and pathlib and splitext will treat it as the stem '.config' with empty extension, rather than an empty sten with ".config" suffix.
I don't know for sure, but files can have multiple extension such as file that are in download state that are something.mp4.crowndowload It's just a guess anyway, I think it would usually work
I was wondering how the old str.rstrip("end") and new str.removesuffix("end") differ, and found the explanation in the pep
Because lstrip takes a string as its argument, it could be viewed as taking an iterable of length-1 strings. The API could, therefore, be generalized to accept any iterable of strings, which would be successively removed as prefixes. While this behavior would be consistent, it would not be obvious for users to have to call 'foobar'.lstrip(('foo',)) for the common use case of a single prefix.
240
u/kankyo Sep 15 '20
This is the big feature right here.