Scope rule pecularities
Antoon Pardon
apardon at forel.vub.ac.be
Fri May 7 04:50:03 EDT 2004
Op 2004-05-07, Josiah Carlson schreef <jcarlson at uci.edu>:
>> Well I would say that seems to go against the intention as stated
>> in the reference manual. += and associated should attempt the
>> operation in place. If you do an operation in place there is
>> no need to rebind the variable.
>
> Except when the /referenced object/ is immutable. Name rebinding is
> necessary to reference the newly created immutable object that was
> created through the +=, -=, /=, %=, *=, &=, |=, or ^= operations.
IMO having operators that should work in place for object that
are immutable, sound contradictory. Having the following code:
a = ...
b = ...
c = a
a += b
I now expect a and c still to be the same object.
--
Antoon Pardon
More information about the Python-list
mailing list