
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 split if gz or zip or...: split again --- Bruce (via android) On Apr 20, 2010 8:36 AM, "Tarek Ziadé" <ziade.tarek@gmail.com> wrote: Hello Currently, os.path.splitext will split a string giving you the piece behind the last dot:
os.path.splitext('file.tar.gz') ('file.tar', '.gz')
In some cases, what we really want is the two last parts when splitting on the dots (like in my example). What about providing an extra argument to be able to grab more than one dot ?
os.path.splitext('file.tar.gz', numext=2) ('file', '.tar.gz')
If numext > numbers of dots, it will just split after the first dot:
os.path.splitext('file.tar', numext=2) ('file', '.tar')
What do you think ? Regards Tarek -- Tarek Ziadé | http://ziade.org _______________________________________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas