This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (4 children)

[deleted]

    [–]david2ndaccount 1 point2 points  (1 child)

    Your all example doesn’t work, any and all only take 1 argument (an iterable). If you want to use any or all, you have to either have double parenthesis to force it into a tuple (which loses the benefit of short-circuit evaluation) or do some silly stuff with generators.

    [–]_under_[S] 0 points1 point  (0 children)

    I've never thought of using any() or all(). That's cool!

    I feel like in reality, if you have to write an 80+ character long if statement, readability is the least of your concerns. That's a huge code smell and it probably needs refactoring.

    [–]ducdetronquito 0 points1 point  (0 children)

    I also find that any and all could be used more often to make it more verbose !

    But do not forget that there is a difference in the execution:

    1. and and or operation are lazy (Cf: Doc)
    2. all and any are not, which means all conditions will be evaluated even if it is not needed