In Python 3, operator.or_ is equivalent to the bitwise |, not the logical or. Why is there no operator for the logical or?
In Python 3, operator.or_ is equivalent to the bitwise | , not the logical
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
orandandoperators can’t be expressed as functions because of their short-circuiting behavior:in these cases,
some_function()is never called.A hypothetical
or_(True, some_function()), on the other hand, would have to callsome_function(), because function arguments are always evaluated before the function is called.