[Python-ideas] 'where' statement in Python?

Carl M. Johnson cmjohnson.mailinglist at gmail.com
Wed Jul 21 02:09:16 CEST 2010


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:

def _():
    index = complicated_formula

x[index] = _() #Probably a NameError

Would the complexity of PEP 3150 be significantly lessened by that? Or
are there other major sources of complexity in the
local/nonlocal/global issue?

2.) What happens in this case:

x = y given:
     return "???"

Do we just disallow return inside a given? If so, how would the parser
know to allow you to do a def inside a given?

-- Carl Johnson



More information about the Python-ideas mailing list