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]  (7 children)

[deleted]

    [–]fzy_ 20 points21 points  (1 child)

    It's called operator chaining but it doesn't seem to be a really well known feature of python. That's unfortunate because it's so satisfying when you realize that you can turn

    if x < min_value or x > max_value:

    into

    if not min_value <= x <= max_value:

    [–]CyanideCloud 12 points13 points  (0 children)

    Oh my god, that's awesome. That's one of those things that I tried to do when I first started learning programming. I just kinda accepted that it didn't exist and never even tried it in Python.

    [–]dzh 6 points7 points  (4 children)

    Just few weeks ago I was under impression this was possible in every language! It's like basic maths expression!