python - Does __ne__ use an overridden __eq__? -


suppose have following program:

class a(object):                                                                                                                                                                                                                                                                   def __eq__(self, other):         return true  a0 = a()  a1 = a()  print a0 != a1 

if run python output true. question

  1. the __ne__ method not implemented, python fall on default one?
  2. if python fall on default method determine whether 2 objects equal or not, shouldn't call __eq__ , negate result?

from the docs:

there no implied relationships among comparison operators. truth of x==y not imply x!=y false. accordingly, when defining __eq__(), 1 should define __ne__() operators behave expected.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -