Record pronouncement on conditional expressions.

This commit is contained in:
Raymond Hettinger 2005-09-30 01:51:58 +00:00
parent f33c46e7ad
commit 14e9b49d96
2 changed files with 33 additions and 4 deletions

View File

@ -63,6 +63,7 @@ Index by Category
Accepted PEPs (accepted; may not be implemented yet)
SA 308 If-then-else expression GvR, Hettinger
SA 328 Imports: Multi-Line and Absolute/Relative Aahz
SA 342 Coroutines via Enhanced Generators GvR, Eby
SA 343 Anonymous Block Redux and Generator Enhancements GvR
@ -203,7 +204,6 @@ Index by Category
SR 295 Interpretation of multiline string constants Koltsov
SR 296 Adding a bytes Object Type Gilbert
SR 303 Extend divmod() for Multiple Divisors Bellman
SR 308 If-then-else expression GvR, Hettinger
SR 310 Reliable Acquisition/Release Pairs Hudson, Moore
SD 312 Simple Implicit Lambda Suzi, Martelli
SR 313 Adding Roman Numeral Literals to Python Meyer
@ -353,7 +353,7 @@ Numerical Index
SF 305 CSV File API Montanaro, et al
I 306 How to Change Python's Grammar Hudson
SF 307 Extensions to the pickle protocol GvR, Peters
SR 308 If-then-else expression GvR, Hettinger
SA 308 If-then-else expression GvR, Hettinger
SF 309 Partial Function Application Harris
S 310 Reliable Acquisition/Release Pairs Hudson, Moore
SF 311 Simplified GIL Acquisition for Extensions Hammond

View File

@ -3,14 +3,43 @@ Title: If-then-else expression
Version: $Revision$
Last-Modified: $Date$
Author: Guido van Rossum, Raymond D. Hettinger
Status: Rejected
Status: Accepted
Type: Standards Track
Content-Type: text/plain
Created: 7-Feb-2003
Post-History: 7-Feb-2003, 11-Feb-2003
Adding a conditional expression
Introduction
On 9/29/2005, Guido decided to add conditional expressions in the
form of "X if C else Y". [1]
The motivating use case was the prevalance of error-prone attempts
to achieve the same effect using "and" and "or". [2]
Previous community efforts to add a conditional expression were
stymied by a lack of consensus on the best syntax. That issue was
resolved by simply deferring to a BDFL best judgment call.
The decision was validated by reviewing the how the syntax fared when
applied throughout the standard library (this review approximates a
sampling of real-world use cases, across a variety of applications,
written by a number of programmers with diverse backgrounds). [3]
References
[1] Pronouncement
http://mail.python.org/pipermail/python-dev/2005-September/056846.html
[2] Motivating use case:
http://mail.python.org/pipermail/python-dev/2005-September/056546.html
http://mail.python.org/pipermail/python-dev/2005-September/056510.html
[3] Review in the context of real-world code fragments:
http://mail.python.org/pipermail/python-dev/2005-September/056803.html
Introduction to earlier draft of the PEP (kept for historical purposes)
Requests for an if-then-else ("ternary") expression keep coming up
on comp.lang.python. This PEP contains a concrete proposal of a