What a curious assignment.

bonono at gmail.com bonono at gmail.com
Wed Nov 23 06:10:21 CET 2005


Neil.Jin at gmail.com wrote:
> [test 1]
> >>> class A:
> ...    i = 1
> ...
> >>> a = A()
> >>> A.i
> 1
> >>> a.i
> 1
> >>> A.i = 2
> >>> A.i
> 2
> >>> a.i
> 2
> >>>
>
> [test2]
> >>> class A:
> ...    i = 1
> ...
> >>> a = A()
> >>> A.i
> 1
> >>> a.i
> 1
> >>> a.i = 2
> >>> A.i
> 1
> >>> a.i
> 2
> >>>
>
> Is there somthing wrong????
I don't think so, the name binding stuff again. Good to know though.




More information about the Python-list mailing list