[Python-ideas] 'where' statement in Python?
ncoghlan at gmail.com
Wed Jul 21 13:07:39 CEST 2010
On Wed, Jul 21, 2010 at 8:53 PM, Guido van Rossum <guido at python.org> wrote:
> On Wed, Jul 21, 2010 at 11:39 AM, Masklinn <masklinn at masklinn.net> wrote:
>> On 2010-07-21, at 02:09 , Carl M. Johnson wrote:
>>> 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?
It's allowing more than simple names on the LHS that makes a naive
return-based approach to name binding not work.
However, it's class scopes that really make this complicated, and
making it "just work" is probably easier than trying to explain which
kinds of assignment will and won't work.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas