Searching in str backwards

Emile van Sebille emile at
Thu Oct 14 01:39:50 CEST 2010

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_
_', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', 
'__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__
', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', 
'__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclass
hook__', '_formatter_field_name_split', '_formatter_parser', 
'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expan
dtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 
'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lo
wer', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 
'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'starts
with', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
 >>> help(line.rfind)
Help on built-in function rfind:

     S.rfind(sub [,start [,end]]) -> int

     Return the highest index in S where substring sub is found,
     such that sub is contained within s[start:end].  Optional
     arguments start and end are interpreted as in slice notation.

     Return -1 on failure.



More information about the Python-list mailing list