Return value of an assignment statement?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Feb 23 01:22:13 CET 2008


On Fri, 22 Feb 2008 11:00:17 -0800, Aahz wrote:

> In article <47be994b$0$6538$426a34cc at news.free.fr>, Bruno Desthuilliers 
> <bruno.42.desthuilliers at wtf.websiteburo.oops.com> wrote:
>>
>>FWIW, it's IMHO a real wart - given Python's pretention at readability -
>>that augmented assignement has been implemented that way for lists.
> 
> This was debated extensively when augmented assignment was created, and
> it was decided that practicality beat purity.  It's just too convenient
> to be able to write
> 
> L += ['foo']
> 
> without rebinding L.


*scratches head*

Wouldn't L.append('foo') or L.extend(['foo']) be even more convenient, 
and have perfectly obvious behaviour without leading to the confusion of 
augmented assignments?

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.



-- 
Steven



More information about the Python-list mailing list