[New-bugs-announce] [issue26514] Object defines '__ne__' as 'not __eq__' if '__ne__' is not implemented

Marc Guetg report at bugs.python.org
Tue Mar 8 16:55:55 EST 2016


New submission from Marc Guetg:

I propose to change __ne__ of `object` in the following form:

	class NewObject(object):
		def __ne__(self, other):
			return not self.__eq__(other)

Currently overwriting the `__eq__` method requires also overwriting `__ne__`. In a vast majority of cases this results in some boilerplate code as:

    (a == b) ^ (a != b) == True

to reduce surprises. Changing the default behavior still allows for the limited number of use cases where we want to implement __ne__ differently.


In short I propose the same behavior than __str__ and __repr__ have for __eq__ and __ne__.
(https://docs.python.org/3/reference/datamodel.html#object.__str__)

----------
components: Interpreter Core
messages: 261385
nosy: Marc Guetg
priority: normal
severity: normal
status: open
title: Object defines '__ne__' as 'not __eq__' if '__ne__' is not implemented
type: enhancement
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26514>
_______________________________________


More information about the New-bugs-announce mailing list