Fix error in examples pointed out by Nicco Kunzmann and mention Haskell influence

This commit is contained in:
Nick Coghlan 2011-08-09 21:37:23 +10:00
parent ee849ab2a0
commit cb20624396
1 changed files with 7 additions and 6 deletions

View File

@ -36,9 +36,10 @@ replacing other techniques that achieve the same effect (such as the "default
argument hack").
The specific proposal in this PEP has been informed by various explorations
of this and related concepts over the years (e.g. [1], [2], [3], [6]). It avoids
some pitfalls that have been encountered in the past, but has not yet itself
been subject to the test of implementation.
of this and related concepts over the years (e.g. [1], [2], [3], [6]), and is
inspired to some degree by the ``where`` and ``let`` clauses in Haskell. It
avoids some problems that have been identified in past proposals, but has not
yet itself been subject to the test of implementation.
PEP Deferral
@ -363,7 +364,7 @@ behaviour is desired::
def f():
return i
seq.append(f)
assert seq == [9]*10
assert [f() for f in seq] == [9]*10
# Current Python (early binding via default argument hack)
seq = []
@ -371,7 +372,7 @@ behaviour is desired::
def f(_i=i):
return i
seq.append(f)
assert seq == list(range(10))
assert [f() for f in seq] == list(range(10))
# Early binding via given clause
seq = []
@ -379,7 +380,7 @@ behaviour is desired::
seq.append(f) given:
def f():
return i
assert seq == list(range(10))
assert [f() for f in seq] == list(range(10))
Note that the current intention is for the copy-in/copy-out semantics to
apply only to names defined in the local scope containing the ``given``