Yet Another Switch-Case Syntax Proposal

Ian Kelly ian.g.kelly at gmail.com
Thu Apr 3 02:50:44 EDT 2014


On Wed, Apr 2, 2014 at 7:06 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> If we're going to add "switch" and "case" keywords, how about we also add
> "of"? Then we can write:
>
> switch x case of a, b, c:
>     # x equals one of a, b or c
> case of d, e, f:
>     # x equals one of d, e or f
> case in g, h, i:
>     # g, h and i must be iterable, and x is in one of them
> else:
>     # none of the above match

I don't think I like the idea of having "case in" and "case of"
meaning two different things, particularly since the one that you have
labeled with "of" is the one that I think should use "in" and vice
versa.  Seems like too much potential for confusion here.



More information about the Python-list mailing list