4 ms·
as a CS major im sure this has academic value. as someone who is just learning python outside of a trade job as an engine mechanic, this idea makes me want to
by nimbius 8y ago
as a CS major im sure this has academic value. as someone who is just learning python outside of a trade job as an engine mechanic, this idea makes me want to glass someone and im not sure why.
(5 < x && x < 10)
if we're talking about X, whats wrong with defining the parameters of its constraints in terms of X instead of dancing around the numbers? 5 < X makes it sound like im setting constraints on the number 5.
- manojlds 8y agoIn python you can just do 5 < x < 10
- wongarsu 8y agowhich is also the proper way you would read in any scientific paper, and very easy to read imho. 5 < x && x < 10 is the attempt to replicate this in other languages but falls a bit short
- saagarjha 8y ago> 5 < x && x < 10 is the attempt to replicate this in other languages but falls a bit short On the contrary, it's Python that added the shorthand, mathematical-looking notation because the longer "desugared" form wasn't great.
- kilburn 8y agoThat's not the contrary, it is exactly what the other comment said ;). "To fall short" == "to not be great"
- mindslight 8y agoActually this has zero academic value. The entire point is as a working programmer to compensate for ambiguous pitfalls in a language. You don't need this specific trick in python (as others have pointed out, `5 < x < 10` works), but in general python holds to a similar philosophy of using standardized idioms to make reading code easier. It's called "being pythonic".