[Python-ideas] range

Nick Coghlan ncoghlan at gmail.com
Thu Feb 28 16:20:02 CET 2013


On Thu, Feb 28, 2013 at 6:43 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> 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?

Yes, I think so. People will have to be *real* convincing to explain a
case where composition isn't a more appropriate solution

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list