The first uses __ne__ objects, and the second uses __eq__ objects and negates its result.
While both methods should combine their result, therefore a == b implies not a != b , this is not actually required or forced.
There are no implied relationships between comparison operators. True x==y does not mean that x!=y is false. Accordingly, when defining __eq__() should also define __ne__() so that the operators act properly.
In your case, where choice is a string (I think?), That doesn't really matter. Built-in types provide feedback between == and != . So the only difference is how clear this is when viewing the code. And I personally prefer a shorter first version.
poke source share