-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return NotImplemented for SortedSet.__and__ #219
Comments
I'm familiar with
It may be easy enough to fix with:
But it's disappointing the |
I think maybe it ought to be: def __and__(self, other):
"""Return the intersection of two sets as a new sorted set.
``ss.__and__(iterable)`` <==> ``ss & iterable``
"""
intersect = self._set.__and__(other)
if intersect is NotImplemented:
return NotImplemented
return self._fromset(intersect, key=self._key) |
Actually I don't believe |
Binary operators such as
__eq__
,__and__
, etc. shouldreturn NotImplemented
in the event that the given argument is an unsupported type rather than raising an error. This allows the other object to patch in its own implementation.Roughly speaking, it means code should be written like this:
This allows cases such as this:
The text was updated successfully, but these errors were encountered: