No, there is no syntax highlighted, using sequential comparisons is the right way to do this already.
One “subtlety” that I can offer is to use decompression first, but this is just the readability of the glaze:
low, high = t if low <= val <= high:
If you use the tuple subclass created by collection.namedtuple() , you can of course use the following attributes:
from collections import namedtuple range_tuple = namedtuple('range_tuple', 'low high') t = range_tuple(1, 2) if t.low <= val <= t.high:
source share