2007年11月23日 星期五 15:29
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)... -------------- ä¸ä¸é¨å -------------- ??HTML?????... URL: http://python.cn/pipermail/python-chinese/attachments/20071123/7ed734ae/attachment.html
2007年11月23日 星期五 15:33
var ÊÇÀàµÄ¾²Ì¬±äÁ¿°É£¬º¯ÊýÊÇʵÀýÓ¦¸Ã²»Ò»Ñù 2007/11/23, Roc Zhou <chowroc.z+l在gmail.com>: > > 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)... > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20071123/042f599c/attachment.htm
2007年11月23日 星期五 15:37
ÄÇô id() ·´Ó³µÄÊÇʲôÄØ£¿ ¶øÇÒÕâÊDz»ÊÇÒâζ×Å x.func ºÍ y.func ÒªÕ¼¾ÝÁ½²¿·ÖÄÚ´æÄØ£¿ On Nov 23, 2007 3:33 PM, littlesea littlesea <wzhlittlesea在gmail.com> wrote: > var ÊÇÀàµÄ¾²Ì¬±äÁ¿°É£¬º¯ÊýÊÇʵÀýÓ¦¸Ã²»Ò»Ñù <http://python.cn/mailman/listinfo/python-chinese> > -- ------------------------------------------------------------------------ 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)... -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20071123/0e9fa29e/attachment.html
2007年11月23日 星期五 15:42
¿ÉÄÜÎÊÌâ³öÔÚ is ÉÏ£¬ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20071123/a6f31e0f/attachment.html
2007年11月23日 星期五 16:04
ÉÏÃæÊÇÔÚ Linux ÏÂÔËÐеĽá¹û¡£ÏÂÃæÊÇ Windows ÏÂÔËÐеĽá¹û£º >>> 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:42 PM, haur <hekun06在gmail.com> wrote: > ¿ÉÄÜÎÊÌâ³öÔÚ is ÉÏ£¬ > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -- ------------------------------------------------------------------------ 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)... -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20071123/7e11609f/attachment.htm
Zeuux © 2025
京ICP备05028076号