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

Duncan Smith buzzard at urubu.freeserve.co.uk
Sat Oct 7 20:14:47 EDT 2006


MonkeeSage wrote:
> On Oct 7, 12:37 pm, Fredrik Lundh <fred... at pythonware.com> wrote:
> 
>>for what?
> 
> 
>   key in self.keys()
> 

[snip]

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).

Duncan



More information about the Python-list mailing list