[Python-ideas] range

Antoine Pitrou solipsis at pitrou.net
Fri Feb 22 15:05:57 CET 2013


Le Thu, 21 Feb 2013 13:35:17 +0000 (UTC),
Wolfgang Maier
<wolfgang.maier at biologie.uni-freiburg.de> a
écrit :
> 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))

-1. range() is a contiguous sequence, not an arbitrary container.
Simplicity is part of its virtues.

Regards

Antoine.





More information about the Python-ideas mailing list