Is this just two ways to write the same code? Is there any functional difference I should be aware of?
>>> a = 'foo'
>>> if not a == 'bar':
... 'its not'
...
'its not'
>>> if a != 'bar':
... 'its not'
...
'its not'
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In python, to check whether or not an object is equal or not equal to another object, special functions are called.
__eq__is called to check==, while__ne__is called to check!=In general, an object could define
__ne__differently than__eq__.E.g.
This yields:
However, this would be especially evil… You usually should never have to worry about this.