python class methods identity?

limodou limodou at gmail.com
Fri Nov 23 03:10:21 EST 2007


On Nov 23, 2007 4:06 PM, Roc Zhou <chowroc.z+l at gmail.com> wrote:
> 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
>
估计只能看源码去了。不管怎么样比较变量的结果是预期的,而比较两个方法似乎是用处不大。

-- 
I like python!
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/
meide <<wxPython UI module>>: http://code.google.com/p/meide/
My Blog: http://www.donews.net/limodou


More information about the Python-list mailing list