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

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,270
    Rep Power
    12
    i still wish for an explanation because i try to sue them in to my code.
    What is now proved was once only imagined!
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

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

    Code:
    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:
    Code:
    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.

    -Mek

    Comments on this post

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

IMN logo majestic logo threadwatch logo seochat tools logo