On Wed, Jul 21, 2010 at 11:39 AM, Masklinn <masklinn@masklinn.net> wrote:
On 2010-07-21, at 02:09 , Carl M. Johnson wrote:
Questions:
1.) It looks like a lot of the complexity of PEP 3150 is based on wanting thing like this to work:
x[index] = 42 given: index = complicated_formula
To make that work, you need to figure out if index is a nonlocal or a global or what in order to emit the right bytecode. What happens if we just give up that use case and say that anything on the assignment side of the initial = gets looked up in the original namespace? In other words, make 3150 more similar to the sugar:
Why do you think it's more complicated to do it for the LHS than for the RHS?
I quite agree with that, the where/given block/scope should only apply to the expression directly to the left of it. So only the RHS should be concerned, and LHS is out of that scope.
And that expression would be written as:
operator.setitem(x, index, 42) given: index = complicated_formula
Bah.
I think the first Torture Test block is misguided, and I'd be -0.5 on such a complex feature.
-- --Guido van Rossum (python.org/~guido)