Re: shouldn't 'string'.find('ugh') return 0, not -1 ?
- From: Hrvoje Niksic <hniksic@xxxxxxxxxx>
- Date: Wed, 31 Oct 2007 15:22:17 +0100
jelle <jelleferinga@xxxxxxxxx> writes:
the subject pretty much says it all.
if I check a string for for a substring, and this substring isn't found,
should't the .find method return 0 rather than -1?
How would you treat the case of 'something' being at the beginning of
the string? After all, find returns the index.
this breaks the
if check.find('something'):
do(somethingElse)
idiom, which is a bit of a pity I think.
if 'something' in check:
do(somethingElse)
.
- References:
- Prev by Date: Re: shouldn't 'string'.find('ugh') return 0, not -1 ?
- Next by Date: Re: shouldn't 'string'.find('ugh') return 0, not -1 ?
- Previous by thread: shouldn't 'string'.find('ugh') return 0, not -1 ?
- Next by thread: Re: shouldn't 'string'.find('ugh') return 0, not -1 ?
- Index(es):
Relevant Pages
|