[Python-Dev] Switch statement

Fredrik Lundh fredrik at pythonware.com
Sat Jun 24 17:03:17 CEST 2006

Josiah Carlson wrote:

> This is a good thing, because if switch/case ends up functionally
> identical to if/elif/else, then it has no purpose as a construct.

there's no shortage of Python constructs that are functionally identical 
to existing constructs.  as with all syntactic "sugar", the emphasis 
should be on what the programmer wants to express, not how you can 
artificially constrain the implementation to make the new thing slightly 
different from what's already in there.

and the point of switch/case is to be able to say "I'm going to dispatch 
on a single value" in a concise way; the rest is optimizations.


More information about the Python-Dev mailing list