Re: string character count

2009-07-02 Thread noydb
thanks everyone for all the ideas -- simple stuff, I know for you all, but very helpful for me. -- http://mail.python.org/mailman/listinfo/python-list

Re: string character count

2009-07-01 Thread Jean-Michel Pichavant
MRAB wrote: noydb wrote: If I have a string for a file name such that I want to find the number of characters to the left of the dot, how can that be done? I did it this way: x = "text12345.txt" dot = x.find('.') print dot Was curious to see what method others would use - helps me learn. I gu

Re: string character count

2009-07-01 Thread Iain King
On Jun 30, 6:27 pm, noydb wrote: > If I have a string for a file name such that I want to find the number > of characters to the left of the dot, how can that be done? > > I did it this way: > x = "text12345.txt" > dot = x.find('.') > print dot > > Was curious to see what method others would use -

Re: string character count

2009-06-30 Thread Emile van Sebille
On 6/30/2009 1:43 PM nn said... On Jun 30, 1:56 pm, MRAB wrote: >>> 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 fi

Re: string character count

2009-06-30 Thread nn
On Jun 30, 1:56 pm, MRAB wrote: > noydb wrote: > > If I have a string for a file name such that I want to find the number > > of characters to the left of the dot, how can that be done? > > > I did it this way: > > x = "text12345.txt" > > dot = x.find('.') > > print dot > > > Was curious to see wh

Re: string character count

2009-06-30 Thread MRAB
noydb wrote: If I have a string for a file name such that I want to find the number of characters to the left of the dot, how can that be done? I did it this way: x = "text12345.txt" dot = x.find('.') print dot Was curious to see what method others would use - helps me learn. I guess I was mos

string character count

2009-06-30 Thread noydb
If I have a string for a file name such that I want to find the number of characters to the left of the dot, how can that be done? I did it this way: x = "text12345.txt" dot = x.find('.') print dot Was curious to see what method others would use - helps me learn. I guess I was most curious to se