overwrite set behavior

Michele Petrazzo michele.petrazzo at TOGLIunipex.it
Thu Sep 4 14:31:23 CEST 2008


Marco Bizzarri wrote:
> looking at the source, maybe you could create a subclass of Set
> redefining the __contains__ method?
> 

Made some tries, but __contains__ are never called

 >>> class foo(set):
...  def __contains__(self, value):
...   print value
...
 >>> a = foo((1,2))
 >>>

Thanks,
Michele



More information about the Python-list mailing list