Augmented Assignment (was: Re: PEP scepticism)
Paul Prescod
paulp at ActiveState.com
Fri Jun 29 15:09:26 EDT 2001
Guido van Rossum wrote:
>
>...
>
> The right way to think about this is "list objects are mutable and
> tuples are not". So if you want to give a library function a sequence
> object of yours but you don't want it to be changed, pass it a tuple.
> If you want it to be changed (or don't care) pass it a list.
My point is that it is hard for a new user to "believe me" (or at least
understand me) when I say that tuples are not mutable but they see them
changing right in front of their eyes:
>>> a=(1,2,3)
>>> a+=(8,3)
The old behaviors strongly emphasized the non-mutability of things. The
new operators undermine that understanding. Maybe the benefits outweigh
this cost but I've seen this misunderstanding myself so I know it is a
real cost.
--
Take a recipe. Leave a recipe.
Python Cookbook! http://www.ActiveState.com/pythoncookbook
More information about the Python-list
mailing list