<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#330033">
    <div class="moz-cite-prefix">On 2/21/2014 3:29 PM, Greg Ewing wrote:<br>
    </div>
    <blockquote cite="mid:5307E177.3080602@canterbury.ac.nz" type="cite">Antoine
      Pitrou wrote:
      <br>
      <br>
      <blockquote type="cite">
        <blockquote type="cite">   lst = [1, 2]
          <br>
             value = lst[2] except IndexError: "No value"
          <br>
        </blockquote>
        <br>
        the gain in concision is counterbalanced by a loss in
        <br>
        readability,
        <br>
      </blockquote>
      <br>
      This version might be more readable:
      <br>
      <br>
         value = lst[2] except "No value" if IndexError
      <br>
      <br>
      since it puts the normal and exceptional values next
      <br>
      to each other, and relegates the exception type (which
      <br>
      is of much less interest) to a trailing aside.
      <br>
    </blockquote>
    <br>
    <br>
    Ternary if teaches us that the normal and alternate values should be
    on either end, so the present proposal corresponds to that; ternary
    if also teaches us that nesting affects the right value, in the
    absence of parentheses, this proposal seems to correspond, although
    requiring parentheses or not is presently a topic of discussion in a
    different subthread.<br>
    <br>
    On the other hand, "if" and "except" are opposites in another way:
    "if" is followed by an expression that, if true, means the left
    value is used, and if false, means the right value is used. 
    "Except" is followed by an exception that, if thrown, means the
    right value is used, and if not thrown, means the left value is
    used... but the word "except" is opposite in meaning to "if", so
    this actually fits nicely with English definitions.<br>
    <br>
    <br>
    Here's a challenge: There has been a big thread about None versus
    (SQL) Null. Show how an except: expression can help the DB API more
    easily convert from using None to using a new Null singleton, and
    you'll have a winner :)<br>
  </body>
</html>