[Python-ideas] range
Terry Reedy
tjreedy at udel.edu
Wed Feb 27 21:43:39 CET 2013
On 2/26/2013 11:46 PM, Raymond Hettinger wrote:
>
> On Feb 23, 2013, at 3:11 AM, Nick Coghlan
> <ncoghlan at gmail.com
> <mailto:ncoghlan at gmail.com>> wrote:
>
>> 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.
>
> I concur. Subclassing range() is just asking for trouble.
The four builtins that cannot be subclassed are bool, memoryview, range,
slice. This is documented for bool; I propose to do so for the others in
http://bugs.python.org/issue17279. Would it be correct to say (now) that
all 4 are intentional omissions? and not merely oversights?
--
Terry Jan Reedy
More information about the Python-ideas
mailing list