# [Python-ideas] Keyword same in right hand side of assignments (rev)

Jacob Holm jh at improva.dk
Tue Mar 17 14:21:46 CET 2009

```Andre Roberge wrote:
>
>
> On Tue, Mar 17, 2009 at 9:23 AM, <hwpuschm at yahoo.de
> <mailto:hwpuschm at yahoo.de>> wrote:
>
>
>     Thank you very much for correctly remarking that the "definition"
>     I formulated contradicts the examples I gave and is therefore
>
>     > It is proposed to introduce a Keyword "same",
>     > to be used in the right hand side of assignments, as
>     > follows:
>
>
>
> I once wrote a blog post on how an expression like "N = N + 1" was
> confusing to beginners, so I'm sympathetic with the underlying idea.
> (http://aroberge.blogspot.com/2005/05/n-n-1.html    Note that there
> are much better explanations for naming objects in Python than this
> old post I wrote.)
>
> However, I am -1 on this proposal.  IMO, it decreases readability and
> achieves very little in terms of clearing up the confusion.
>
> Quick test: which is the easier to read and get right?
>
> n = same + 1
> n = sane + 1
> n = n + 1
>
I believe that as soon as the left-hand side stops being a simple
variable and it is used in non-trivial expressions on the right-hand
side, using the keyword would help clarify the intent.  What I mean is
that the examples you should be looking at are more like:

A[n+1] = same*same + 1
B[2*j].foo = frobnicate(same, same+1)
...

If you try expanding these into current python with minimal change in
semantics you will end up with something like

_1 = n+1
_2 = A[_1]
A[_1] = _2*_2 + 1
del _1
del _2

_1 = B[2*j]
_2 = _1.foo
_1.foo = frobnicate(_2, _2+1)
del _1
del _2