I want to be able to pass arguments like this:
fn(a>=b) or fn(a!=b)
I saw this behavior in DjangoORM and SQLAlchemy but I don't know how to achieve it.
I want to be able to pass arguments like this:
fn(a>=b) or fn(a!=b)
I saw this behavior in DjangoORM and SQLAlchemy but I don't know how to achieve it.
ORMs use special methods on classes for a
and b
to hook into operators and customise what is produced.
>=
for is handled by the object.__ge__()
method, while !=
calls object.__ne__()
.
Typically, the ORM object used for a
returns a new object with the operation applied, allowing you to chain operations, and the fn()
function expects such an ORM object and will read the operation status from there.