开发者

what does 'objects being subclassable' mean?

开发者 https://www.devze.com 2023-03-17 01:57 出处:网络
Dive into Python - Different programming languages define “object” in different ways. In some, i开发者_Python百科t means that all objects must have attributes and methods; in others, it means tha

Dive into Python -

Different programming languages define “object” in different ways. In some, i开发者_Python百科t means that all objects must have attributes and methods; in others, it means that all objects are subclassable. In Python, the definition is looser; some objects have neither attributes nor methods (more on this in Chapter 3), and not all objects are subclassable (more on this in Chapter 5).

I am coming from C++/Java background.


To be subclassable means that you can inherit from them. e.g.

class Foo(object):
    pass

object here is subclassable because Foo can inherit from it.


In this context I think it is talking about Inheritance or Interfaces. As in, you can subclass a Human into Male and Female.

0

精彩评论

暂无评论...
验证码 换一张
取 消