Contents
Python 类型和对象
Copyright © 2005-2009 Shalabh Chaturvedi All Rights Reserved.
关于本书
解释新式的Python对象(new-style):
<type 'type'> and <type 'object'>是什么东西
- 用户定义的类及实例是如何相互关联的,和内置类型有啥关系how user defined classes and instances are related to each other and to built-in types
- metaclass是什么
新式类型New-style包含在Python2.2及以上,包括3.x。这些版本之间会有细微差异,不过这里涉及到的概念都是无差别的。本书讲的内容通常被称作Python类型系统或Python对象模型Python type system, or the object model.
- 本书是以下系列的一部分:
- Python Types and Objects [即你所看到的]
This revision: 1.24
Author: [email protected]
图索引
- 1.1. 空白状态
- 2.1. 鸡和蛋的关系
- 2.2. 一些内置类型
- 2.3. 用户定义对象
- 3.1. Python对象图
- 4.1. 关系
- 4.2. 关系的传递
示例索引
2.1. 查看 <type 'object'> 和 <type 'type'>
2.2. 关于 <type 'object'> 和 <type 'type'>的更多内容
- 2.3. 查看一些内置类型
- 2.4. 通过子类化构建对象
- 2.5. 通过实例化构建对象
- 2.6. 使用class关键字定义类时指定一个type对象
- 3.1. 更多内置 types
- 3.2. 查看旧式类 classic classes
需要提前了解的
1. 基本概念
Object内部
#Example 1.1. 查看integer对象
>>> two = 2 1 >>> type(two) <type 'int'> 2 >>> type(type(two)) <type 'type'> 3 >>> type(two).__bases__ (<type 'object'>,) 4 >>> dir(two) 5 ['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__format__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__', '__index__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'conjugate', 'denominator', 'imag', 'numerator', 'real']
空白状态
对象之间的关系
2.引入对象
第一批对象
更多内置类型
子类化产生新对象
实例化产生新对象
其实都是实例化的
3. 总结一下
Python对象图
概要
好多内置类型还有个名字
这些有什么意义
经典类型Classic Classes
4. 可能在其他地方学过的
面向对象
相关资料
反馈
创建 by -- ZoomQuiet [2010-01-28 16:19:11]