list index()

zzbbaadd at aol.com zzbbaadd at aol.com
Thu Aug 30 19:39:24 EDT 2007


On Aug 30, 4:28 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
wrote:
> zzbba... at aol.com writes:
> > On Aug 30, 12:09 am, Ben Finney <bignose+hates-s... at benfinney.id.au>
> > wrote:
> > > It's letting you know that the item isn't in the list. There's no
> > > sensible return value from an "index" function in that condition.
>
> > for str:
> > find(      sub[, start[, end]])
> > [...]
> > Return -1 if sub is not found.
>
> > -1 is used in other languages as well.
>
> It is no more sensible there than in the 'str.find' method, which is a
> historical wart.

One man's sensible is another man's insensible. For instance, some
people feel -1 as a valid index into a list is sensible. Other's find
it insensible.

>
> --
>  \     "Hey Homer! You're late for English!"  "Pff! English, who needs |
>   `\       that? I'm never going to England!"  -- Barney & Homer, _The |
> _o__)                                                        Simpsons_ |
> Ben Finney





More information about the Python-list mailing list