Can't get around "IndexError: list index out of range"

MonkeeSage MonkeeSage at gmail.com
Sat Oct 7 20:25:15 EDT 2006



On Oct 7, 7:14 pm, Duncan Smith <buzz... at urubu.freeserve.co.uk> wrote:
> No.  The above constructs a list of keys and searches the list for the
> key, O(n).  "key in somedict" is a lookup, O(1).

My point wasn't in regard to implementation details, but in regard to
convenience methods. Obviously the sugary dict methods are tweaked for
the best performance (one would hope!), as would be sugary sequence
methods were they to be added. What I was wondering is why
dict.has_key() and get() are there but not list.has_index() and get().

Regards,
Jordan




More information about the Python-list mailing list