Python 中的面向对象编程:定义类¶
我们之前说过Python是一种面向对象的编程语言。 到目前为止,我们已经使用了许多内置类来展示数据和控制结构的示例。 面向对象编程语言中最强大的功能之一是能够允许程序员(问题解决者)创建新类来对解决问题所需的数据进行建模。
请记住,我们使用抽象数据类型来提供数据对象的外观(其状态)及其功能(其方法)的逻辑描述。 通过构建实现抽象数据类型的类,程序员可以利用抽象过程,同时提供在程序中实际使用抽象所需的详细信息。 每当我们想要实现抽象数据类型时,我们都会使用一个新类来实现。
原文
Object-Oriented Programming in Python: Defining Classes
We stated earlier that Python is an object-oriented programming language. So far, we have used a number of built-in classes to show examples of data and control structures. One of the most powerful features in an object-oriented programming language is the ability to allow a programmer (problem solver) to create new classes that model data that is needed to solve the problem.
Remember that we use abstract data types to provide the logical description of what a data object looks like (its state) and what it can do (its methods). By building a class that implements an abstract data type, a programmer can take advantage of the abstraction process and at the same time provide the details necessary to actually use the abstraction in a program. Whenever we want to implement an abstract data type, we will do so with a new class.
创建日期: 2023年10月10日