The answer here gives a handwaving reference to cases where you’d want __ne__ to return something other than just the logical inverse of __eq__, but I can’t imagine any such case. Any examples?
The answer here gives a handwaving reference to cases where you’d want __ne__ to
Share
SQLAlchemy is a great example. For the uninitiated, SQLAlchemy is a ORM and uses Python expression to generate SQL statements. In a expression such as
the
model.Theme.id == model.VoteWarn.post_iddoes not return a boolean, but a object that eventually produces a SQL query likeWHERE theme.id = vote.post_id. The inverse would produce something likeWHERE theme.id <> vote.post_idso both methods need to be defined.