Duncan Booth <[EMAIL PROTECTED]> wrote:
>Ville Vainio wrote:
>>>>>>> "Peter" == Peter Hansen <[EMAIL PROTECTED]> 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?
That's what I meant (and why I wrote "str." not "string.").
>The name index implies it returns something you can use as an index to get
>at the substring.
Unfortunately, -1 can of course be used as an index. Mind you, it
would be perverse to expect to find the substring at it.
--
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu become� se bera eadward ofdun hl�ddre heafdes b�ce bump bump bump
--
http://mail.python.org/mailman/listinfo/python-list