[Python-Dev] Switch statement

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Jun 25 06:48:14 CEST 2006


Phillip J. Eby wrote:

> 1. "case (literal|NAME)" is the syntax for equality testing -- you can't 
> use an arbitrary expression, not even a dotted name.

That's too restrictive. I want to be able to write
things like

   class Foods:
     Spam = 1
     Eggs = 2
     Ham = 3

  ...

     switch f:
       case Foods.Spam:
         ...
       case Foods.Eggs:
         ...

--
Greg


More information about the Python-Dev mailing list