Python的本质值,需要澄清

时间:2013-07-11 16:36:41

标签: python

我刚读完http://python.net/crew/mwh/hacks/objectthink.htmlhttp://nedbatchelder.com/text/names.html

现在有一个问题,Python值总是对象(对象是唯一可以绑定的东西吗?)而且,对象是PyTown中唯一的游戏...因为语言不具备原语,对吗?

1 个答案:

答案 0 :(得分:3)

它一直是物体,是的。

例如,

整数有方法:

>>> 1 .__str__
<method-wrapper '__str__' of int object at 0x104ad7820>

功能也是如此:

>>> def foo(): pass
... 
>>> foo.__str__
<method-wrapper '__str__' of function object at 0x104e62830>