Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an implication logical operator in python?

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?

like image 721
running.t Avatar asked May 06 '13 19:05

running.t


People also ask

What is the correct operator for implication?

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.

What are the 3 logical operators in Python?

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.

Do Python have logical operators?

Python has three logical operators: and , or , and not .


2 Answers

p => q is the same as not(p) or q, so you could try that!

like image 174
Juan Pablo Rinaldi Avatar answered Sep 22 '22 22:09

Juan Pablo Rinaldi


Just because it's funny: x => y could be bool(x) <= bool(y) in python.

like image 44
Adam Sosnowski Avatar answered Sep 23 '22 22:09

Adam Sosnowski