PEP: statements in control structures (Re: Conditional Expressions don't solve the problem)

Paul Boddie paul at boddie.net
Thu Oct 18 13:07:09 CEST 2001


huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) wrote in message news:<slrn9sruhl.ll.huaiyu at gauss.almadan.ibm.com>...
>

Sorry if someone already raised this point, but...

>         The semantics of 
>         
>             if stmts1; expr1:
>                 stmts2
>             elif stmts3; expr2:
>                 stmts4
>             elif stmts5; expr3:
>                 stmts6
>             else:
>                 stmts7

And couldn't this be written as...

  stmts1; if expr1:
    stmts2
  else:
    stmts3; if expr2:
      stmts4
    else:
      stmts5; if expr3:
        stmts6
      else:
        stmts7

...?

Of course, you're indenting more and using a few more lines, but don't
you think that it's frivolous to implement a language change merely to
be able to move the statements to the right of the keyword, admittedly
allowing some merging of keywords as a result?

Paul



More information about the Python-list mailing list