[Python-checkins] python/nondist/peps pep-0308.txt,1.4,1.5

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Fri, 07 Feb 2003 14:34:58 -0800


Update of /cvsroot/python/python/nondist/peps
In directory sc8-pr-cvs1:/tmp/cvs-serv6424

Modified Files:
	pep-0308.txt 
Log Message:
Add if C : e1 else e2.


Index: pep-0308.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0308.txt,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pep-0308.txt	7 Feb 2003 22:29:39 -0000	1.4
--- pep-0308.txt	7 Feb 2003 22:34:54 -0000	1.5
***************
*** 72,75 ****
--- 72,76 ----
      to C-derived language, it is hard to understand.
  
+     ---
  
      David Ascher proposed, and Eric Raymond even implemented, a
***************
*** 82,85 ****
--- 83,87 ----
      easier to understand than the ?: form.
  
+     ---
  
      If we could live with adding a new keyword, we could use:
***************
*** 100,103 ****
--- 102,126 ----
      is a requirement for being Pythonic -- list comprehensions don't).
  
+     ---
+ 
+     To deal with the problem of adding a new keyword, this variant has
+     been proposed:
+ 
+         if <condition> : <expression1> else <expression2>
+ 
+     This has the same ambiguity problem as the previous one (I would
+     even say more so), and lacks symmetry.  It also begs the question
+     why there isn't a colon after the 'else'.  But this:
+ 
+         if <condition> : <expression1> else: <expression2>
+ 
+     is even more confusing because it resembles the if statement so
+     much.  (A solution that *doesn't* resemble the if statement is
+     better IMO since it should be obvious at first glance whether
+     we're dealing with an if expression or with an if statement.
+     Placing the 'if' in the middle somehow satisfies this
+     requirement.)
+ 
+     ---
  
      Many people suggest adding a new builtin instead of extending the