Return value of an assignment statement?

Steve Holden steve at holdenweb.com
Sat Feb 23 08:31:11 EST 2008


Paul Rubin wrote:
> Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
>> Personally, I think the confusion of augmented assignments is not worth 
>> the benefit of saving typing a couple of characters. I think Guido's 
>> first decision, to leave += etc out of the language, was the right 
>> decision.
> 
> It quite helpful to be able to say
> 
>   foo['bar'+lookup(baz)][blob(a)+frob(b)] += 1
> 
> without having to split it into separate statements to avoid repeating
> the function calls and their possible side effects.

And that was the reason for eventually including them. I remember being 
very surprised when I learned that rebinding was possible at the option 
of the implementing object, but of course rebinding is inevitable when 
you have immutable objects that implement augmented assignments.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list