Is __ne__ method autogenerated?

I

Ian Kelly

The reference says:

The truth of x==y does not imply that x!=y is false.
Accordingly, when defining __eq__(), one should also
define __ne__() so that the operators will behave as expected.

(http://docs.python.org/3/reference/datamodel.html#object.__eq__)

But I saw different behavior on 3.3:
https://gist.github.com/4231096

Could anyone teach me what happen about my code?

http://docs.python.org/3/whatsnew/3.0.html#operators-and-special-methods

I can't find it documented anywhere else.
 
C

Chris Rebert

The reference says:

The truth of x==y does not imply that x!=y is false.
Accordingly, when defining __eq__(), one should also
define __ne__() so that the operators will behave as expected.

(http://docs.python.org/3/reference/datamodel.html#object.__eq__)

But I saw different behavior on 3.3:
https://gist.github.com/4231096

Could anyone teach me what happen about my code?

The reference is not completely accurate in this case. See
http://bugs.python.org/issue4395
"Document auto __ne__ generation; [...]"
 
I

INADA Naoki

Thanks a million!


The reference says:

The truth of x==y does not imply that x!=y is false.
Accordingly, when defining __eq__(), one should also
define __ne__() so that the operators will behave as expected.

(http://docs.python.org/3/reference/datamodel.html#object.__eq__)

But I saw different behavior on 3.3:
https://gist.github.com/4231096

Could anyone teach me what happen about my code?

The reference is not completely accurate in this case. See
http://bugs.python.org/issue4395
"Document auto __ne__ generation; [...]"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top