python class methods identity?
Roc Zhou
chowroc.z+l at gmail.com
Fri Nov 23 02:29:20 EST 2007
Hello,
I'm now being confused by this segment of code:
>>> class Test:
... var = 1
... def func(self): pass
...
>>> x = Test()
>>> y = Test()
>>> x.var is y.var
True
>>> x.func is y.func
False
>>> id(x.var); id(y.var)
146132400
146132400
>>> id(x.func); id(y.func)
-1208243388
-1208243388
Since both "var" and "func" are the variable of the class object, and
x.var is y.var, why x.func is not y.func while their id() return the
same value.
Thanks.
--
------------------------------------------------------------------------
My Projects:
http://sourceforge.net/projects/crablfs
http://www.yourlfs.org/
http://www.yourlfs.org/#ru_data_man
http://www.yourlfs.org/tree.html
http://www.yourlfs.org/sysadm_zh_CN.html
My Blog:
http://chowroc.blogspot.com/
Looking for a space and platform to exert my originalities (for my
projects)...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071123/7ed734ae/attachment.html>
More information about the Python-list
mailing list