虽然可以通过属性访问对象的类型,但它的类型不仅仅是一个属性——该类型定义了对象在拥有任何属性之前是如何创建的。仅凭这个事实,这些语句都不足以描述Python对象。

我这么说:In Python, everything is an object.

An object is a block of information, which has a type, which defines its creation and how it interacts with other objects, an identity, which differentiates it from all other objects, and a value, which is the information in the block. Attributes are other objects associated with a given object, including the object that is its type.

然后,您应该给出一些人们可能不希望成为对象的例子,比如函数。

关于“什么是对象”的段落可以在Dive Into Python中找到:Everything in Python is an object, and almost everything has attributes and methods. All functions have a built-in attribute __doc__, which returns the doc string defined in the function's source code. The sys module is an object which has (among other things) an attribute called path. And so forth.

Still, this begs the question. What is an object? Different programming languages define “object” in different ways. In some, it 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). But everything is an object in the sense that it can be assigned to a variable or passed as an argument to a function (more in this in Chapter 4).

python类属性描述_如何描述Python对象,以及属性、标识、类型和值之间的关系?...相关推荐

  1. python 类定义 垃圾_什么是python对象摧毁?python中的对象摧毁(垃圾回收)机制是什么?...

    在这篇文章之中我们来了解一下python对象摧毁(垃圾回收),对于刚刚接触到python这一编程语言的朋友来说,对于python对象摧毁(垃圾回收)的了解应该比较少,并且不清楚关于python垃圾回收 ...

  2. python类和函数_构建程序. Python中的类和函数

    如果希望mainfunc的所有实例都使用相同的KeySeq对象,则可以使用默认参数值技巧: def mainfunc(ks=KeySeq()): key = ks.next() 只要您实际上没有传递k ...

  3. python类的应用_如何剖析python应用程序的类方法?

    过去,我在同一文件中编写了具有所有功能的python代码,并且可以使用以下代码来分析我的程序: 这是我写的装饰器: def do_profile(cond): def resdec(f): if no ...

  4. python类中函数_如何在Python类中使用模块函数

    参见英文答案 > How do you call a private module function from inside a class?                           ...

  5. python类高级用法_十.python面向对象高级用法

    1.反射 1.1 什么是反射 反射的概念是由Smith在1982年首次提出的,主要是指程序可以访问.检测和修改它本身状态或行为的一种能力(自省).这一概念的提出很快引发了计算机科学领域关于应用反射性的 ...

  6. python 分类变量回归_极简Python带你探索分类与回归的奥秘

    为何使用人工智能和机器学习? 地球的未来在于人工智能和机器学习.如果对这些技术一无所知,人们很快会发现自己落伍了.世界发展日新月异,每天都发生着不可思议的变化.在人工智能和机器学习中,有许多实现和技术 ...

  7. python怎么避免浅拷贝_深度解读Python深拷贝与浅拷贝问题

    Illustrations by Leon Tukker ♚ 作者:PayneLi,Python全家桶,主要讲述数据挖掘.机器学习和深度学习领域的前沿技术,同时还会推荐一些行业最新论文.技术专家的经验 ...

  8. boost::python模块实现使用内置 python 数据类型创建 ndarrays 的示例,并提取成员变量的类型和值测试程序

    boost::python模块实现使用内置 python 数据类型创建 ndarrays 的示例,并提取成员变量的类型和值测试程序 实现功能 C++实现代码 实现功能 boost::python模块实 ...

  9. python特性描述_详解 Python 最优雅的特性之一 — 描述符

    本篇选自 Python黑魔法指南 -> 第四章 -> 第2节. github仓库: https://github.com/iswbm/magic-python magic-python 目 ...

最新文章

  1. java命令执行类,这里设置了classpath,系统变量里的classpath将失效
  2. python编程输入标准-Python练习题,,T1.编写程序,输入
  3. Mysql 8主从复制配置图解
  4. 07 / LiveVideoStack主编观察:走,卷海外去
  5. 16 --删除排序数组中的重复项
  6. 为什么自己编写的页面总是在那里抖动_「内存抖动」?别再吓唬面试者们了行吗...
  7. DB2 存储过程中执行动态SQL的两种写法
  8. git 命令commit_Git Commit命令解释
  9. 寻找链表倒数第k个节点
  10. c语言参数传入函数赋值后传出来,c语言第10次实验内容函数2邹显春.ppt
  11. 帝国cms数据库php调用tag,帝国CMS列表内容模板调用TAG的两种方法
  12. Delphi 两种类的声明方法
  13. Redis3.2.5 集群搭建以及Spring-boot测试
  14. redis 客户端连接及常用命令使用
  15. 关于神经网络中隐藏层和神经元的深入理解
  16. 区块链交易——举例说明
  17. 【自我介绍】小白程序员的成神之路
  18. python:numpy的corrcoef计算相关系数
  19. 出入库与库存系统的模型问题
  20. 在线传输文件的方法有哪些?镭速云帮您领略最快文件传输的攻略!

热门文章

  1. SolrJ搜索功能切换到集群
  2. idea加入springboot插件_带你搭一个SpringBoot+SpringData JPA的环境
  3. 强烈推荐:Spring 核心知识点总结.pdf
  4. 快手二面:引入RabbitMQ后,你如何保证全链路数据100%不丢失?
  5. 后端必备的200本书,一次性给你!
  6. Spring Boot项目整合Retrofit最佳实践,最优雅的HTTP客户端工具!
  7. UI组件之TextView及其子类(三)ToggleButton和Switch
  8. 【版本工具】Git-浅谈git命令
  9. Dungeon Master(三维bfs)java
  10. system文件_大文件拷贝,试试NIO的内存映射