<p>When would you know in advance you want 2 parts? Compare file.tar.gz to backup.2010.04.20.tar. I'd think the usual case would be</p>
<p>split <br>
if gz or zip or...:<br>
  split again<br></p>
<p>--- Bruce<br>
(via android)</p>
<p><blockquote type="cite">On Apr 20, 2010 8:36 AM, "Tarek Ziadé" <<a href="mailto:ziade.tarek@gmail.com">ziade.tarek@gmail.com</a>> wrote:<br><br>Hello<br>
<br>
Currently, os.path.splitext will split a string giving you the piece<br>
behind the last dot:<br>
<br>
>>> os.path.splitext('file.tar.gz')<br>
('file.tar', '.gz')<br>
<br>
In some cases, what we really want is the two last parts when<br>
splitting on the dots (like in my example).<br>
<br>
What about providing an extra argument to be able to grab more than one dot ?<br>
<br>
>>> os.path.splitext('file.tar.gz', numext=2)<br>
('file', '.tar.gz')<br>
<br>
If numext > numbers of dots, it will just split after the first dot:<br>
<br>
>>> os.path.splitext('file.tar', numext=2)<br>
('file', '.tar')<br>
<br>
<br>
What do you think ?<br>
<br>
Regards<br>
Tarek<br>
<font color="#888888"><br>
<br>
<br>
<br>
<br>
<br>
--<br>
Tarek Ziadé | <a href="http://ziade.org" target="_blank">http://ziade.org</a><br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</font></blockquote></p>