[Python-ideas] Keyword same in right hand side of assignments (rev)
Jacob Holm
jh at improva.dk
Wed Mar 18 01:43:52 CET 2009
Steven D'Aprano wrote:
> One last question -- what should happen here?
>
> x, y, z = (same, same+1, same+2)
>
>
>
Obviously a typeerror, as you cannot add one or two to a tuple... :)
But the same question for the statement
x, y, z = (same, foo(same), bar(same))
has a simple obvious anwer (at least to my eyes). It should be
equivalent to:
tmp = x, y, z
z, y, z = (tmp, foo(tmp), bar(tmp))
However, On rereading the proposal(s), I can see that all the operations
using same are supposedly defined in terms of augmented assignment
operators which really doesn't make any sense to me. (Augmented
assignment is one of the very few things in python I find really
unclean. I know practicality beats purity and all that, but it just
doesn't sit right with me).
It is quite possible that I have been interpreting this whole idea
differently than the original author intended. If so, I apologize for
the confusion. In any case I am at best -0.5 on it, because the benefit
does not outweigh the cost of adding a new keyword.
Jacob
More information about the Python-ideas
mailing list