<div dir="ltr">Hi all,<div><br></div><div>It seems to me that the correct algorithm to get the "full suffix" is not to take everything after the FIRST dot,</div><div>but rather to:</div><div>1. Recognize that the last suffix is one of the UNIX-style compression tools .Z, .gz, ,bz2, .xz, .lzma (at least)</div><div>2. Then add the next-to-last suffix.</div><div><br></div><div>So we can then determine that the suffix of</div><div> order.for.tar.ps.gz</div><div>is .ps.gz and the basename is order.for.tar .</div><div><br></div><div>However, I am not sure if we want to hard-code a list of such suffixes in the standard library.</div><div>(Even though it could be user-extensible.)</div><div><br></div><div>Stephan</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-01-25 16:33 GMT+01:00 Todd <span dir="ltr"><<a href="mailto:toddrjen@gmail.com" target="_blank">toddrjen@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Wed, Jan 25, 2017 at 10:18 AM, Petr Viktorin <span dir="ltr"><<a href="mailto:encukou@gmail.com" target="_blank">encukou@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_5981436288783929575gmail-">On 01/25/2017 04:04 PM, Todd wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_5981436288783929575gmail-">
On Wed, Jan 25, 2017 at 12:25 AM, Stephen J. Turnbull<br>
<<a href="mailto:turnbull.stephen.fw@u.tsukuba.ac.jp" target="_blank">turnbull.stephen.fw@u.tsukuba<wbr>.ac.jp</a><br></span><span class="m_5981436288783929575gmail-">
<mailto:<a href="mailto:turnbull.stephen.fw@u.tsukuba.ac.jp" target="_blank">turnbull.stephen.fw@u.<wbr>tsukuba.ac.jp</a>>> wrote:<br>
<br>
I'm just going to let fly with the +1s and -1s, don't take them too<br>
seriously, they're basically impressionistic (I'm not a huge user of<br>
pathlib yet).<br>
<br>
Todd writes:<br>
<br>
> So although the names are tentative, perhaps there could be a<br>
"fullsuffix"<br>
> property to return the extensions as a single string,<br>
<br>
-0 '.'.join(p.suffixes) vs. p.fullsuffix? TOOWTDI says no. I<br>
also don't really see the use case.<br>
<br>
<br>
The whole point of pathlib is to provide convenience functions for<br>
common path-related operations. It is full of methods and properties<br>
that could be implemented other ways.<br>
<br>
Dealing with multi-part extensions, at least for me, is extremely<br>
common. A ".tar.gz" file is not the same as a ".tar.bz2" or a<br>
".svg.gz". When I want to find a ".tar.gz" file, having to deal with<br>
the ".tar" and ".gz" parts separately is nothing but a nuisance. If I<br>
want to find and extract ".rar" files, I don't want ".part1.rar" files,<br>
".part2.rar" files, and so on. So for me dealing with the extension as<br>
a single unit, rather than individual parts, is the most common approach.<br>
</span></blockquote>
<br>
But what if the .tar.gz file is called "spam-4.2.5-final.tar.gz"?<br>
Existing tools like glob and endswith() can deal with the ".tar.gz" extension reliably, but "fullsuffix" would, arguably, not give the answers you want.<br></blockquote></div></div><div><br><br>I wouldn't use it in that situation. The existing "suffix" and "stem" properties also only work reliably under certain situations.<br> </div><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Perhaps more specialized tools would be useful, though, for example:<br>
repacked_path = original_path.replace_suffix("<wbr>.tar.gz", ".zip")<div class="m_5981436288783929575gmail-HOEnZb"><div class="m_5981436288783929575gmail-h5"><br></div></div></blockquote></span></div><br></div><div class="gmail_extra">That is helpful if I want to rename, not if I want to (for example) uncompress a file.<br></div></div>
<br>______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br></blockquote></div><br></div>