[Python-Dev] Switch statement

Benji York benji at benjiyork.com
Mon Jun 19 23:59:12 CEST 2006


Delaney, Timothy (Tim) wrote:
 > Guido van Rossum wrote:
 >
 >
 >>I wonder if there should be two default clauses, or some other
 >>syntactic way to indicate whether we expect all x to be hashable?
 >
 >
 >     switch expr:
 >         case 1:
 >             statements
 >         case 2:
 >             statements
 >         else:
 >             statements
 >         except KeyError:
 >             statements
 >         finally:
 >             statements

Small variation:

switch expr:
     case 1:
         statements
     case 2:
         statements
     else:
         statements
     except:
         statements
--
Benji York


More information about the Python-Dev mailing list