[Python-Dev] Switch statement (original) (raw)
Phillip J. Eby pje at telecommunity.com
Wed Jun 21 14:29:54 CEST 2006
- Previous message: [Python-Dev] Switch statement
- Next message: [Python-Dev] Switch statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 03:38 AM 6/21/2006 -0500, Ka-Ping Yee wrote:
On Wed, 21 Jun 2006, Phillip J. Eby wrote: > Well, EIBTI and all that: > > switch x: > case == 1: foo(x) > case in S: bar(x) > > It even lines up nicely. :)
Hmm, this is rather nice. I can imagine possible use cases for switch x: case > 3: foo(x) case is y: spam(x) case == z: eggs(x) An interesting use case for which this offers no corresponding syntax is case instanceof ClassA: ham(x)
Actually, I was assuming that any other operator besides == and 'in' would be relegated to an if-elif chain in the default case, although it's almost possible to do that automatically, I suppose.
- Previous message: [Python-Dev] Switch statement
- Next message: [Python-Dev] Switch statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]