__eq__ and sets
tim.one at comcast.net
Wed Feb 26 06:35:30 CET 2003
[Gareth McCaughan, on Set() == 2]
> In what sense would comparing addresses give a nonsense result here?
I don't think it would, and that's why I suggested the datetime gimmick
(special-casing __eq__ and __ne__ in ways not special-cased by the other 4
> If x is a Set and y is not a Set, then (1) it will fall back to
> comparing addresses, (2) that will say that they're not equal,
> and (3) that's what you want in general. If y is of some funny
> type that wants to compare equal to certain Sets, then it's up
> to the implementors of that type to make it happen by not returning
> Presumably I'm missing something. What?
I was channeling the likely intent of the orginal author(s)' code -- the
idea of special-casing __eq__ and __ne__ is relatively new, and hasn't
caught on yet. I doubt it was considered when sets.py was written, and that
the desire to stop falling back to address-based comparison in general was
assumed to require stopping it in all cases.
More information about the Python-list