June 14th, 2013, 05:52 AM
i still wish for an explanation because i try to sue them in to my code.
What is now proved was once only imagined!
June 14th, 2013, 08:21 AM
Look. In 99.9% of the use cases for and and or the only concern is the Boolean evaluation of the expression. These expressions evaluate the way they do because it is both sufficient and occasionally useful. All you need to know is that the value that they evaluate to is fully sufficient for establishing the Boolean value of the expression.
What you are concerned with in your past attempts has never been the Boolean evaluation of the expression. You are getting hung up on a specific detail of how the python interpreter functions for no reason.
could be a conceivably useful line in many programs, and here all that is of interest is the Boolean evaluation (although using all would still be better).
if (a and b and c):
Your line however:
would not be useful in any but the most esoteric of codes, as you are no longer interested in the Boolean evaluation of the expression in parenthesis at all.
if x in (a and b and c):
Are there cases where it is important to know which exact value it will evaluate to? Sure. But they are certainly not common. It is far more important that you understand how the expression evaluates to True or False.
Comments on this post