Re: Searching in str backwards

2010-10-13 Thread Chris Kaynor
Look up the string's rfind method. Chris On Wed, Oct 13, 2010 at 4:28 PM, Pratik Khemka wrote: > I want to search for a symbol in a string backwards.. > For eg: > > *line = "my/cat/dog/baby"* > ** > *line.find('/')* *# but from the back...* > > The reason I want to do this is because I want t

Re: Searching in str backwards

2010-10-13 Thread Emile van Sebille
On 10/13/2010 4:28 PM Pratik Khemka said... line = "my/cat/dog/baby" Introspection is your friend >>> line = "my/cat/dog/baby" >>> dir(line) ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem_ _', '__getnewar

Searching in str backwards

2010-10-13 Thread Pratik Khemka
I want to search for a symbol in a string backwards.. For eg: line = "my/cat/dog/baby" line.find('/') # but from the back... The reason I want to do this is because I want to print the last part of the string after the '/' . And I do not know how long the string might be or how many '/' i