What's the equivalent of AndAlso (&&) and OrElse (||) logical operators in Python?
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Realization
--
Chapters
00:00 What'S The Equivalent Of Andalso (&Amp;&Amp;) And Orelse (||) Logical Operators In Python?
00:59 Answer 1 Score 0
01:13 Accepted Answer Score 8
01:31 Thank you
--
Full question
https://stackoverflow.com/questions/4757...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #python27 #logicaloperators #equivalent
#avk47
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Realization
--
Chapters
00:00 What'S The Equivalent Of Andalso (&Amp;&Amp;) And Orelse (||) Logical Operators In Python?
00:59 Answer 1 Score 0
01:13 Accepted Answer Score 8
01:31 Thank you
--
Full question
https://stackoverflow.com/questions/4757...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #python27 #logicaloperators #equivalent
#avk47
ACCEPTED ANSWER
Score 8
Python already does this:
def foo():
print ("foo")
return True
def bar():
print ("bar")
return False
print (foo() or bar())
print ("")
print (bar() or foo())
Returns:
foo
True
bar
foo
True
There is no need for AndAlso or OrElse in Python, it evaluates boolean conditions lazily (docs).
ANSWER 2
Score 0
In python, you can use logic gates.
You can use either, for instance, and or &.
https://docs.python.org/2/library/stdtypes.html#bitwise-operations-on-integer-types