[Python-checkins] python/nondist/peps pep-0340.txt, 1.26, 1.27 pep-0342.txt, 1.1, 1.2
gvanrossum@users.sourceforge.net
gvanrossum at users.sourceforge.net
Thu May 12 00:10:56 CEST 2005
Update of /cvsroot/python/python/nondist/peps
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10442
Modified Files:
pep-0340.txt pep-0342.txt
Log Message:
Note that 'yield' w/o an EXPR is currently illegal.
Index: pep-0340.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0340.txt,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- pep-0340.txt 11 May 2005 21:58:31 -0000 1.26
+++ pep-0340.txt 11 May 2005 22:09:37 -0000 1.27
@@ -383,13 +383,16 @@
Examples
+ (Several of these examples contain "yield None". If PEP 342 is
+ accepted, these can be changed to just "yield" of course.)
+
1. A template for ensuring that a lock, acquired at the start of a
block, is released when the block is left:
def locking(lock):
lock.acquire()
try:
- yield
+ yield None
finally:
lock.release()
@@ -421,7 +424,7 @@
def transactional(db):
try:
- yield
+ yield None
except:
db.rollback()
raise
@@ -433,7 +436,7 @@
def auto_retry(n=3, exc=Exception):
for i in range(n):
try:
- yield
+ yield None
return
except exc, err:
# perhaps log exception here
@@ -498,7 +501,7 @@
save_stdout = sys.stdout
try:
sys.stdout = new_stdout
- yield
+ yield None
finally:
sys.stdout = save_stdout
Index: pep-0342.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0342.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- pep-0342.txt 11 May 2005 21:58:43 -0000 1.1
+++ pep-0342.txt 11 May 2005 22:09:37 -0000 1.2
@@ -140,6 +140,12 @@
are all illegal. (Some of the edge cases are motivated by the
current legality of "yield 12, 42".)
+ Note that a yield-statement or yield-expression without an
+ expression is now legal. This makes sense: when the information
+ flow in the next() call is reversed, it should be possible to
+ yield without passing an explicit value ("yield" is of course
+ equivalent to "yield None").
+
When __next__() is called with an argument that is not None, the
yield-expression that it resumes will return the argument. If it
resumes a yield-statement, the value is ignored (this is similar
More information about the Python-checkins
mailing list