Skip to content
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

__ne__() logic #639

Closed
bblay opened this issue Jul 24, 2013 · 1 comment · Fixed by #641
Closed

__ne__() logic #639

bblay opened this issue Jul 24, 2013 · 1 comment · Fixed by #641
Assignees

Comments

@bblay
Copy link
Contributor

bblay commented Jul 24, 2013

Following on from #633, implmentations of __ne__ which look for NotImplemented should be calling __eq__ directly, rather than ==, because the return value get's booled.
So from this:

    # Must supply __ne__, Python does not defer to __eq__ for negative equality
    def __ne__(self, other):
        result = self == other
        if result != NotImplemented:
            result = not result
        return result

To this:

    # Must supply __ne__, Python does not defer to __eq__ for negative equality
    def __ne__(self, other):
        result = self.__eq__(other)
        if result != NotImplemented:
            result = not result
        return result
@ghost ghost assigned bblay Jul 24, 2013
@cpelley
Copy link

cpelley commented Jul 24, 2013

wow thats a rather unexpected behavioural difference

@bblay bblay mentioned this issue Jul 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants