Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #69671
| References | <8084-1396540962-768613@sneakemail.com> <mailman.8852.1396550862.18130.python-list@python.org> <533e6e58$0$29993$c3e8da3$5496439d@news.astraweb.com> <87ioqpqvef.fsf@elektro.pacujo.net> |
|---|---|
| Date | 2014-04-04 10:02 -0600 |
| Subject | Re: Yet Another Switch-Case Syntax Proposal |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8894.1396627349.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
On Apr 4, 2014 3:51 AM, "Marko Rauhamaa" <marko@pacujo.net> wrote:
>
> >>> switch day casein ("Monday", "Thursday", "Wednesday", "Tuesday",
> >>> "Friday"):
> >>> gotowork = True
> >>> continue
> >>> casein ("Monday", "Thursday", "Wednesday", "Tuesday", "Friday"):
> >>> daytype = "ferial"
> >>> casein ("Saturday", "Sunday")
> >>> daytype = "festive"
>
> That "casein" next to "switch" bugs me. Did I already propose:
>
> switch: local_sabbath()
> case (1, 2, 3) as sabbath:
> ...
> case 6:
> ...
> else:
> ...
I don't get what this is intended to do. First, why is the expression in
the first line after the colon? That doesn't match any existing block
syntax (as you note it matches lambda, but that's an expression-level
syntax). What's wrong with the much more natural "switch local_sabbath():"?
Second, "as" clauses are used in other contexts for local assignment. What
is the purpose of doing that here? How does this solve the problem of
explicitly denoting case multiplicity?
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Yet Another Switch-Case Syntax Proposal Ethan Furman <ethan@stoneleaf.us> - 2014-04-03 11:23 -0700
Re: Yet Another Switch-Case Syntax Proposal Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-04-04 08:33 +0000
Re: Yet Another Switch-Case Syntax Proposal Marko Rauhamaa <marko@pacujo.net> - 2014-04-04 12:46 +0300
Re: Yet Another Switch-Case Syntax Proposal Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-04 10:02 -0600
Re: Yet Another Switch-Case Syntax Proposal Marko Rauhamaa <marko@pacujo.net> - 2014-04-04 19:44 +0300
Re: Yet Another Switch-Case Syntax Proposal Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-04 11:55 -0600
csiph-web