
Feb. 27, 2013
8:43 p.m.
On 2/26/2013 11:46 PM, Raymond Hettinger wrote:
On Feb 23, 2013, at 3:11 AM, Nick Coghlan <ncoghlan@gmail.com <mailto:ncoghlan@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