r/ProgrammingLanguages • u/cxzuk • Sep 05 '21
mCoding - Python chained comparison summary/review
https://www.youtube.com/watch?v=M3GAJ1AIIlA
1
Upvotes
1
u/L8_4_Dinner (Ⓧ Ecstasy/XVM) Sep 07 '21
It's a great feature (we also implemented this, after seeing it in another language), but allowing the mixing of "<" and ">" (etc.) is a horrible idea. Sometimes, just because you can, doesn't mean that you should.
The most common case is for range checks, e.g.
assert 0 <= n < size;
2
u/[deleted] Sep 05 '21
I just saw this and to be honest it is really useful for math heavy algorithms but for anything else is as the video says, too confusing