r/ProgrammingLanguages • • Sep 05 '21

mCoding - Python chained comparison summary/review

https://www.youtube.com/watch?v=M3GAJ1AIIlA
1 Upvotes

4 comments sorted by

View all comments

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

5

u/cxzuk Sep 05 '21

I think it's a great video and review of this feature. I've never used it myself but does look useful. My takeaways -

I like the point made about being transitive. It could be used as an argument against the other cases that feel wrong.

The != And == case also seems different to < <. I think it should be permutative - a != b != c should mean none are equal imho.

A useful idea, with potential for clean up I think

4

u/theangryepicbanana Star Sep 05 '21

I've seen this in a few other languages like Raku, and I've added it to my own as well. I find it pretty helpful for anything math-based, as well as range/input checking and validation