The type/object distinction and possible synthesis of OOP and imperative programming languages
Ethan Furman
ethan at stoneleaf.us
Tue Apr 16 13:29:18 EDT 2013
On 04/16/2013 01:25 AM, Serhiy Storchaka wrote:
> On 16.04.13 07:46, Ian Kelly wrote:
>> On Mon, Apr 15, 2013 at 9:17 PM, Terry Jan Reedy <tjreedy at udel.edu> wrote:
>>> I will keep the above in mind if I write or review a patch. here are 4
>>> non-subclassable builtin classes. Two are already documented. Bool in one,
>>> forget which other. I believe it was recently decided to leave the other two
>>> as is given the absence of any practical use case.
>>
>> The four are bool, NoneType, slice and ellipsis, I believe.
>
> --> import builtins
> --> for n in dir(builtins):
> ... if type(getattr(builtins, n)) is type:
> ... try:
> ... t = type(n, (getattr(builtins, n),), {})
> ... except TypeError as e:
> ... print(e)
> ...
> type 'bool' is not an acceptable base type
> type 'memoryview' is not an acceptable base type
> type 'range' is not an acceptable base type
> type 'slice' is not an acceptable base type
Well that bumps our count to five then:
--> NoneType = type(None)
--> NoneType
<class 'NoneType'>
--> class MoreNone(NoneType):
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: type 'NoneType' is not an acceptable base type
--
~Ethan~
More information about the Python-list
mailing list