Dear all,
what do you think about allowing the use of operators on ranges?
I thought of things like:
a = range(1,10)
b = range(5,12)
intersect = a & b # equivalent to intersect = range(5,10)
merge = a | b # equivalent to merge = range(1,12)
to make this work in more complex cases, like:
a = range(1,10)
b = range(12,15)
merge = a | b # equivalent to sth. like range(range(1,10),range(12,15))
maybe range nesting would be desirable, but the full sequence of values of such
a nested range could still be calculated on demand.
Such syntax would allow for the generation of more complex sequences, and, as a
side-effect, ranges could also be checked for overlap easily:
if a & b:
do_something()
this whole idea is reminiscent, of course, of what's implemented for sets
already, so like there you could think of
intersect = a & b as shorthand for intersect = a.intersection(b)
Opinions?