diff --git a/pep-0572.rst b/pep-0572.rst index c5ee7eacde1..f2662190d58 100644 --- a/pep-0572.rst +++ b/pep-0572.rst @@ -136,13 +136,14 @@ scope, which will succeed; but it will evaluate everything else in a function:: prefixed_names = (iter(names)) The name ``prefix`` is thus searched for at global scope, ignoring the class -name. Under the proposed semantics, this name will be eagerly bound, being -approximately equivalent to:: +name. Under the proposed semantics, this name will be eagerly bound; and the +same early binding then handles the outermost iterable as well. The list +comprehension is thus approximately equivalent to:: class X: names = ["Fred", "Barney", "Joe"] prefix = "> " - def (prefix=prefix): + def (names=names, prefix=prefix): result = [] for name in names: result.append(prefix + name) @@ -159,8 +160,7 @@ be late-bound as usual. One consequence of this change is that certain bugs in genexps will not be detected until the first call to ``next()``, where today they would be -caught upon creation of the generator. TODO: Discuss the merits and costs -of amelioration proposals. +caught upon creation of the generator. See 'open questions' below. Recommended use-cases