Can't get around "IndexError: list index out of range"
buzzard at urubu.freeserve.co.uk
Sun Oct 8 03:16:49 CEST 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().
All I can say is that, I personally, would have little use for those
list methods. Those involved in the design of the language will no
doubt have much better reasons than this.
More information about the Python-list