
On Sat, Feb 23, 2013 at 12:05 AM, Antoine Pitrou <solipsis@pitrou.net> wrote:
Le Thu, 21 Feb 2013 13:35:17 +0000 (UTC), Wolfgang Maier <wolfgang.maier@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.
-1 from me as well. We don't even implement concatenation and repetition for ranges in order to keep them simple - we have to caveat the range docs to point out they don't *quite* implement the full sequence API due to this restriction. However, I will note that starting in Python 3.3, range objects expose their "start", "stop" and "step" attributes. That makes it much easier for third party software to manipulate them arithmetically. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia