best way to increment an IntVar?

Dave Angel davea at ieee.org
Fri Jun 25 15:52:13 EDT 2010


Alan G Isaac wrote:
> <div class="moz-text-flowed" style="font-family: -moz-fixed">On 
> 6/25/2010 1:14 PM, Dave Angel wrote:
>> the default behavior of += is to assign a new object with the new value,
>> rather than changing the previous object.
>
>>>> a = []
>>>> temp = a
>>>> a += [2]
>>>> temp
> [2]
>
> Alan Isaac
>
>
I said "default", not "only" behavior.   I suspect list provides an 
__iadd__  method to provide this ability.  Integers do not, and  
therefore neither does the object the OP was asking about.

DaveA



More information about the Python-list mailing list