Static variable vs Class variable
Diez B. Roggisch
deets at nospam.web.de
Tue Oct 9 16:27:47 EDT 2007
More information about the Python-list mailing list
Tue Oct 9 16:27:47 EDT 2007
- Previous message (by thread): Static variable vs Class variable
- Next message (by thread): Static variable vs Class variable
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Steven D'Aprano schrieb: > On Tue, 09 Oct 2007 19:23:37 +0200, Diez B. Roggisch wrote: > >> Your believes aside, this is simply wrong. The statement >> >> a += x >> >> always leads to a rebinding of a to the result of the operation +. > > Not true. Yes, it is. >>>> L = [] >>>> id(L) > 3083496716L >>>> L += [1] >>>> id(L) > 3083496716L > > It's the same L, not rebound at all. Just because the __iadd__-operation in the list implemented chose to returen a reference to itself - certainly a sensible choice, I never doubted that - doesn't change the fact that python rebinds the name on the left with whatever __iadd__ returned. Diez
- Previous message (by thread): Static variable vs Class variable
- Next message (by thread): Static variable vs Class variable
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list