set of sets

Matteo Dell'Amico della at
Fri Aug 12 08:45:02 CEST 2005

Paolo Veronelli wrote:
> Yes this is really strange.
> from sets import Set
> class H(Set):
>   def __hash__(self):
>     return id(self)
> s=H()
> f=set() #or f=Set()
> f.add(s)
> f.remove(s)
> No errors.
> So we had a working implementation of sets in the library an put a 
> broken one in the __builtins__ :(
> Should I consider it a bug ?

Looks like the builtin "set" implicitly converts sets arguments to 
remove to frozensets. That way, remove looks for "frozenset()" instead 
of "H()", so it won't work. Doesn't look like a documented behaviour to 
me, though.


More information about the Python-list mailing list