magical expanding hash
Jean-Paul Calderone
exarkun at divmod.com
Tue Jan 17 21:24:28 EST 2006
On Tue, 17 Jan 2006 16:47:15 -0800, James Stroud <jstroud at ucla.edu> wrote:
>braver wrote:
>> Well, I know some python, but since there are powerful and magical
>> features in it, I just wonder whether there're some which address this
>> issue better than others.
>>
>
>In python, += is short, of course, for
>
>a = a + 1
>
No it's not. It's short for
if isinstance(a, object):
if hasattr(a.__class__, '__iadd__'):
_x = a.__class__.__iadd__(a, b)
if _x is NotImplemented:
a = b + a
else:
a = _x
else:
a = b + a
else:
if hasattr(a, '__iadd__'):
_x = a.__iadd__(b)
if _x is NotImplemented:
a = b + a
else:
a = _x
else:
a = b + a
Roughly speaking, anyway. Not that this is relevant to your point.
Jean-Paul
More information about the Python-list
mailing list