[Python-Dev] Switch statement

Phillip J. Eby pje at telecommunity.com
Mon Jun 12 01:59:21 CEST 2006

At 12:44 AM 6/12/2006 +0200, Fredrik Lundh wrote:
>the compiler can of course figure that out also for if/elif/else state-
>ments, by inspecting the AST.  the only advantage for switch/case is
>user syntax...

Not quite true - you'd have to restrict the switch expression in some way, 
so you don't have:

    if x.y == 1:
    elif x.y == 2:

where the compiler doesn't know if getattr(x,'y') is really supposed to 
happen more than once.  But I suppose you could class that as syntax.

More information about the Python-Dev mailing list