Augmented Assignement (was: Re: PEP scepticism)
Rainer Deyke
root at rainerdeyke.com
Sun Jul 1 18:08:31 EDT 2001
"Tim Peters" <tim.one at home.com> wrote in message
news:mailman.993952381.32699.python-list at python.org...
> As usual in this debate, the participants aren't *themselves* confused
about
> it, they're worried about people much feebler than they are. In this
> particular case, don't be so sure that isn't an empty set <wink>.
You misunderstand my position. I am only concerned about myself. Newbies
mean nothing to me, maintainers mean nothing to me, and I'll happily use
code like "([a] or [b] and [c])[0]". I'm worried about conceptual overhead
and correctness.
Conceptual overhead: I can learn simple things and I can learn complex
things, but I've found that I am more productive when using simple and
flexible tools than I am when working with complex tools. This is one of
the reasons why I prefer Python over C++.
Correctness: Consider the following function:
def f(x):
x += (1, 2, 3)
print x
This function is just plain incorrect. If I want a function that mutates
its argument, it should not accept immutable objects. If I want a function
that does not mutate its argument, the above is simply incorrect. There is
no conceivable case where I would want a function that mutates or does not
mutate its object based on the mutability of the object.
In fact, it is quite possible that the function above fails to mutate a
mutable argument if the type/class of the argument was not written to
support augmented assignment. Once this oversight is corrected, my
function's semantics change and my program breaks.
--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
More information about the Python-list
mailing list