Python 类型和对象

Shalabh Chaturvedi

Copyright © 2005-2009 Shalabh Chaturvedi
All Rights Reserved.

(小明同学译 wjm251 AT gmail.com

关于本书

解释新式的Python对象(new-style):

新式类型New-style包含在Python2.2及以上,包括3.x。这些版本之间会有细微差异,不过这里涉及到的概念都是无差别的。本书讲的内容通常被称作Python类型系统或Python对象模型Python type system, or the object model.

This revision: 1.24

图索引

示例索引

需要提前了解的

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]