r/ProgrammerTIL • • Sep 12 '17

Python [Python] TIL that you can chain comparisons

69 Upvotes

16 comments sorted by

View all comments

Show parent comment

3

u/cdrini Sep 12 '17 edited Sep 12 '17

I wouldn't say you have to be particularly careful; I think the universe handles that for you. I can't imagine that situations which require chaining 4 comparison operators come up very frequently in normal programming. In the super rare case that the need does arise, I'm not so sure this syntax is any more awkward to read than 4 anded expressions.

E: grammar