[Python-Dev] Switch statement
Ka-Ping Yee
python-dev at zesty.ca
Wed Jun 21 10:38:57 CEST 2006
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)
which doesn't work because Python spells a type test as
isinstance(a, b) rather than with an operator. (I suppose
whether we want it to be an operator might be another
question to think about for Python 3000.)
-- ?!ng
More information about the Python-Dev
mailing list