J
Jp Calderone
Aahz said:Rainer:
l[x * 2 + f(y)] = f(l[x * 2 + f(y)])
This statement contains an obvious redundancy that will make code
maintenance difficult. Python allows me to factor out some of the
redundancy:
index = x * 2 + f(y)
l[index] = f(l[index])
However, Python gives me no way to factor out the remaining
redundancy.
Sure it does: change the immutable to a mutable.
Not good enough.
Why not? Note that you're playing what is IMO an unfair game where you
keep changing the goalposts.
I'd rather write "l[x] = f(l[x])" with all of its redundancy than wrap
every conceivable immutable object in a mutable wrapper. Besides, I
don't *want* 'f' to change an object (which may also be referenced
elsewhere); I want it to change a binding.
Well, you're going to have to pay for what you want in some fashion;
Python's going to keep its default semantics, so you're going to need
*some* kind of wrapper.
Up for a new operator?
l[index] ()= f
<1.5-wink>, Jp