Augmented Assignment (was: Re: PEP scepticism)
paulp at ActiveState.com
Sun Jul 1 07:05:46 CEST 2001
> >> 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)
> They would believe you better if you gave a better example:
It's funny how this discussion just goes around and around in circles. I
say: "this is initially confusing" and someone else responds with "yes,
but if you spend a whole bunch of effort and show them a long and
complicated list of commands and explain some details of Python's object
orientation it all becomes clear." Yes well, with enough explanation,
even Perl is clear.
In my experience, mutability and references are already one of the
hardest things to teach and understand in Python. They are somewhat
tricky in any language. Anything that makes them more tricky is
questionable in my opinion.
I don't always have the opportunity to talk to people and explain
confusing things to them. In one class I gave, a guy let out a gasp when
he came to understand the reference rules. He said that that was what
had prevented him from coming to understand Python the first two times
he tried. Now I think we've made life harder for guys like that to save
Numeric Python users from typing a method call for their mutations.
That's a poor trade-off.
Take a recipe. Leave a recipe.
Python Cookbook! http://www.ActiveState.com/pythoncookbook
More information about the Python-list