Just remember that Python is sexy

Ville Vainio ville at spammers.com
Thu May 26 03:24:07 EDT 2005


>>>>> "Peter" == Peter Hansen <peter at engcorp.com> writes:

    Peter> Sion Arrowsmith wrote:
    >> But can you come up with a method for remembering which way
    >> round str.find() and str.index() are?

    Peter> Don't use "str" and you won't have anything to remember:

    Peter> 'foo bar baz'.find('spam')
    Peter> 'spanish inquisition'.index('parrot')

But which one raises an exception, and which one returns -1?

-- 
Ville Vainio   http://tinyurl.com/2prnb



More information about the Python-list mailing list