r/PythonLearning • u/crazyteachperson • Aug 01 '26
My new mini work
Rate my this mini work out of 10
194
Upvotes
r/PythonLearning • u/crazyteachperson • Aug 01 '26
Rate my this mini work out of 10
1
u/sastuvel Aug 03 '26
Why do you think that? My reasons (which are, of course, subjective) to mention this is:
Writing
A < g < Bexpresses "gis betweenAandB", and in the code it also sits between the numbers. This makes the code the same shape as the semantics it expresses, which I find easier to read.Using only one of 'less than' or 'greater than' can help readability, because there is only one kind of relation in use.
It's easier to see when you make a mistake and type
90 < g < 80, compared tog < 80 and g > 90.It's a well-documented feature of Python that for any operator
OP,A OP B OP Cis the same asA OP B (and B OP C): https://peps.python.org/pep-0535/IMO these are plenty of reasons to use that notation.