set of sets
Matteo Dell'Amico
della at toglimi.linux.it
Fri Aug 12 02:45:02 EDT 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.
--
Ciao,
Matteo
More information about the Python-list
mailing list