[Python-Dev] PEP 340: What is "ret" in block statement semantics?

Skip Montanaro skip at pobox.com
Fri Apr 29 16:48:24 CEST 2005


PEP 340 describes the block statement translation as:

        itr = EXPR1
        val = arg = None
        ret = False
        while True:
            try:
                VAR1 = next(itr, arg)
            except StopIteration:
                if ret:
                    return val
                if val is not None:
                    raise val
                break
            try:
                val = arg = None
                ret = False
                BLOCK1
            except Exception, val:
                arg = StopIteration()

It uses a variable "ret" that is always False.  If it does manage to take on
a True value, a return statement is executed.  How does ret become True?
What's meaning of return in this context?  Something seems amiss.

Skip


More information about the Python-Dev mailing list