This is the result comes from the Linux. And the result from Windows is: >>> 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) 11228488 >>> id(y.var) 11228488 >>> id(x.func) 14430976 >>> id(y.func) 14433656 >>>
On Nov 23, 2007 3:29 PM, Roc Zhou <[EMAIL PROTECTED]> wrote: > 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)...
-- http://mail.python.org/mailman/listinfo/python-list