Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #69570

Re: Yet Another Switch-Case Syntax Proposal

References <12008-1396450399-453900@sneakemail.com> <mailman.8822.1396475455.18130.python-list@python.org> <533cb3fd$0$2909$c3e8da3$76491128@news.astraweb.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2014-04-03 00:50 -0600
Subject Re: Yet Another Switch-Case Syntax Proposal
Newsgroups comp.lang.python
Message-ID <mailman.8826.1396507894.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Apr 2, 2014 at 7:06 PM, Steven D'Aprano <steve@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.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Yet Another Switch-Case Syntax Proposal Chris Angelico <rosuav@gmail.com> - 2014-04-03 08:50 +1100
  Re: Yet Another Switch-Case Syntax Proposal Steven D'Aprano <steve@pearwood.info> - 2014-04-03 01:06 +0000
    Re: Yet Another Switch-Case Syntax Proposal Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-03 00:50 -0600

csiph-web