[Python-checkins] peps: Add a clarifying paragraph to PEP 0479, and another post-history date.
python-checkins at python.org
Thu Nov 20 19:56:12 CET 2014
user: Guido van Rossum <guido at python.org>
date: Thu Nov 20 10:55:48 2014 -0800
Add a clarifying paragraph to PEP 0479, and another post-history date.
pep-0479.txt | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/pep-0479.txt b/pep-0479.txt
@@ -8,7 +8,7 @@
+Post-History: 15-Nov-2014, 19-Nov-2014
@@ -179,6 +179,20 @@
in favor of changing list comprehensions to match generator
expressions (!), the other was in favor of this PEP's main proposal.
+The existing model has been compared to the perfectly-acceptable
+issues inherent to every other case where an exception has special
+meaning. For instance, an unexpected ``KeyError`` inside a
+``__getitem__`` method will be interpreted as failure, rather than
+permitted to bubble up. However, there is a difference. Dunder
+methods use ``return`` to indicate normality, and ``raise`` to signal
+abnormality; generators ``yield`` to indicate data, and ``return`` to
+signal the abnormal state. This makes explicitly raising
+``StopIteration`` entirely redundant, and potentially surprising. If
+other dunder methods had dedicated keywords to distinguish between
+their return paths, they too could turn unexpected exceptions into
+``RuntimeError``; the fact that they cannot should not preclude
+generators from doing so.
Repository URL: https://hg.python.org/peps
More information about the Python-checkins