On Sat, Feb 23, 2013 at 7:21 PM, Terry Reedy firstname.lastname@example.org wrote:
On 2/22/2013 1:43 PM, Antoine Pitrou wrote:
On Fri, 22 Feb 2013 17:40:29 +0000 (UTC) Wolfgang Maier email@example.com
Any plans to make range a valid base class to build upon in future releases?
I suppose it wouldn't very difficult to make range subclassable. You can try writing a patch if you want: http://docs.python.org/devguide/
I was just about to suggest that making range subclassable would be an alternative to extending the current class. As far as I know, there is no principled reason why not, unlike Nonetype and bool.
I wasn't even aware you *couldn't* subclass it (I'd never tried). As far as I am aware, that's just a quirk inherited from the old xrange implementation rather than a deliberate design decision.
On the other hand, I suspect for many cases involving more advanced range variants, containment would be a better option than inheritance, particular if you want to implement a type that can't be reliably described through a (start, stop, step) triple.