Logical AND, OR and NOT and bitwise AND and OR and bitwise invertion
condition_not_func()
and not_func()
and use
Make one function for metamodel['ConditionNot'].func = property(partial(not_func, operator=operator.invert))
metamodel['Not'].func = property(partial(not_func, operator=operator.not_))
and_func()
and or_func()
Make one function for metamodel['ConditionAnd'].func = property(partial(binary_operation_func, operator=operator.and_))
metamodel['ConditionOr'].func = property(partial(binary_operation_func, operator=operator.or_))
metamodel['And'].func = property(partial(binary_operation_func, operator=lambda x, y: x and y))
metamodel['Or'].func = property(partial(binary_operation_func, operator=lambda x, y: x or y))
Note: It might be dangerous to replace logical or
and and
with bitwise operator.or_
(|
) and operator.and_
(&
) but in our language the operands are always boolean i.e. the results will be the same. But the behavior will be possibly different due to short circuiting of "and" and "or" because they are not proper operators.