I would like to write a statement in python with logical implication. Something like:
if x => y:
do_sth()
Of course, I know I could use:
if (x and y) or not x:
do_sth()
But is there a logical operator for this in python?
The overlapped implication operator is denoted by the |-> symbol. The evaluation of the consequent starts immediately on the same clock cycle if the antecedent holds true. The consequent is not evaluated if the antecedent is not true.
There are three logical operators that are used to compare values. They evaluate expressions down to Boolean values, returning either True or False . These operators are and , or , and not and are defined in the table below.
Python has three logical operators: and , or , and not .
p => q
is the same as not(p) or q
, so you could try that!
Just because it's funny: x => y could be bool(x) <= bool(y)
in python.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With