Static variable vs Class variable

Hrvoje Niksic hniksic at xemacs.org
Wed Oct 17 09:57:35 EDT 2007


Marc 'BlackJack' Rintsch <bj_666 at gmx.net> writes:

> Simply not to introduce special cases I guess.  If you write ``x.a
> += b`` then `x.a` will be rebound whether an `a.__iadd__()` exists
> or not.  Otherwise one would get interesting subtle differences with
> properties for example.  If `x.a` is a property that checks if the
> value satisfies some constraints ``x.a += b`` would trigger the set
> method only if there is no `__iadd__()` involved if there's no
> rebinding.

Note that such constraint is easily invalidated simply with:

foo = x.a
foo += b



More information about the Python-list mailing list