Page 2 of 2 First 12
  • Jump to page:
  1. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Rep Power
    i still wish for an explanation because i try to sue them in to my code.
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Rep Power
    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.

    if (a and b and c):
    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).

    Your line however:
    if x in (a and b and c):
    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.

    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

    • Nik agrees
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo