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


Groups > comp.lang.python > #69671

Re: Yet Another Switch-Case Syntax Proposal

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'syntax': 0.04; 'explicitly': 0.05; 'matches': 0.07; 'contexts': 0.09; 'here?': 0.09; '(1,': 0.16; '3:51': 0.16; 'assignment.': 0.16; 'clauses': 0.16; 'propose:': 0.16; 'subject:Case': 0.16; 'wrote:': 0.18; 'do.': 0.18; '>>>': 0.22; '&gt;&gt;&gt;': 0.24; '&gt;': 0.26; 'first,': 0.26; 'switch': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'second,': 0.31; 'bugs': 0.33; 'problem': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'next': 0.36; 'wrong': 0.37; 'skip:& 10': 0.38; 'to:addr:python- list': 0.38; 'skip:& 20': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'expression': 0.60; 'solve': 0.60; 'first': 0.61; 'more': 0.64; 'natural': 0.68; 'day': 0.76; 'subject:Proposal': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Z5nPu5/1NJy2hxEJhQmYUo1heZ6f1kDFMkLyAy8+Z8c=; b=BGuc9F/I1GlMLN2zLWQWQrfTOfw/DF4pXfpAqt7/QL3XgFAba1hk6wVQLORffG/BWm etSStI/E31w01Ww8df32PmJWyNlD08xhy+eh0GmPyPkFpH/Ew8w/OTCwIyR1tQLw56sO D/pdDFYBjVP1GqZSBOe4OwoEfx5V9CL8wh0z8Hgj6656B88ggBOrjKBsNyuEFSEOSaD8 Hee1gZCzlEtP/wGw41/aotLtzf29vF3cH9J1ZWxu1jJ5v2lGgg2+abdeNwS48eF1G1Yh Rbw1cmf+QW9NAgGTwckZoAD6oFd3bECLSVQbIj2BJns0eAYEJnHq5N6Knn7CmGwlS04b uaUg==
MIME-Version 1.0
X-Received by 10.66.240.70 with SMTP id vy6mr15880491pac.80.1396627341568; Fri, 04 Apr 2014 09:02:21 -0700 (PDT)
In-Reply-To <87ioqpqvef.fsf@elektro.pacujo.net>
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 Fri, 4 Apr 2014 10:02:21 -0600
Subject Re: Yet Another Switch-Case Syntax Proposal
From Ian Kelly <ian.g.kelly@gmail.com>
To Python <python-list@python.org>
Content-Type multipart/alternative; boundary=047d7b15aba993edcb04f639a45d
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.8894.1396627349.18130.python-list@python.org> (permalink)
Lines 73
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1396627349 news.xs4all.nl 2936 [2001:888:2000:d::a6]:41531
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:69671

Show key headers only | View raw


[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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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