On Sat, Jun 22, 2013 at 12:01 PM, Rotwang <sg...@hotmail.co.uk> wrote: >>>> class hashablelist(list): > ... def __hash__(self): > ... return hash(tuple(self))
There's a vulnerability in that definition: >>> a=hashablelist((1,[],3)) >>> a [1, [], 3] >>> {a:1} Traceback (most recent call last): File "<pyshell#255>", line 1, in <module> {a:1} File "<pyshell#249>", line 3, in __hash__ return hash(tuple(self)) TypeError: unhashable type: 'list' Of course, if you monkey-patch list itself to have this functionality, or always use hashablelist instead of list, then it will work. But it's still vulnerable. ChrisA -- http://mail.python.org/mailman/listinfo/python-list