The type/object distinction and possible synthesis of OOP and imperative programming languages

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Apr 15 22:32:59 EDT 2013


On Mon, 15 Apr 2013 20:52:58 -0400, Terry Jan Reedy wrote:

> On 4/15/2013 1:43 PM, Antoon Pardon wrote:
> 
>> $ python3
>> Python 3.2.3 (default, Feb 20 2013, 17:02:41) [GCC 4.7.2] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>>  >>> class vslice (slice):
>> ...   pass
>> ...
>> Traceback (most recent call last):
>>    File "<stdin>", line 1, in <module>
>> TypeError: type 'slice' is not an acceptable base type
>>
>>
>> It seems types and classes are still not mere synonyms.
> 
> Some builtin classes cannot be subclassed. There is an issue to document
> which better. That does not mean that it is not a class.


I think it is also important to document whether that is a language 
feature, or a mere restriction of the implementation. There is an 
important distinction to be made between:

"In CPython, you cannot subclass slice or FunctionType. Other Pythons may 
have more, or fewer, restrictions."

and:

"No language that calls itself Python is permitted to allow slice and 
FunctionType to be subclassable."


If I had a say in this, I would vote for the first case, with the 
possible exception of documented singleton types like NoneType and bool.



-- 
Steven



More information about the Python-list mailing list