On 6/30/2009 1:43 PM nn said...
On Jun 30, 1:56 pm, MRAB <pyt...@mrabarnett.plus.com> wrote:
<snip>

 >>> len("text12345.txt".split(".", 1)[0])
9
 >>> len("textstringwithoutdot".split(".", 1)[0])
20

Also:


>>> len("text.12345.txt".partition('.')[0])
4
>>> len("text.12345.txt".rpartition('.')[0])
10
>>>

unless you've got file names like text.12345.txt, where you might prefer rpartition.

>>> len("text.12345.txt".partition('.')[0])
4
>>> len("text.12345.txt".rpartition('.')[0])
10
>>>

Emile

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to