Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'syntax': 0.04; 'anyway.': 0.05; 'instance.': 0.09; 'parsing': 0.09; 'cc:addr:python-list': 0.11; 'language.': 0.14; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'oddity': 0.16; 'slight': 0.16; 'subject:Case': 0.16; 'syntax,': 0.16; 'wrote:': 0.18; 'normally': 0.19; '(in': 0.22; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'michael': 0.29; 'chris': 0.29; 'am,': 0.29; 'said,': 0.30; 'strongly': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'block,': 0.31; 'comparison': 0.31; 'once,': 0.31; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'proposals': 0.36; 'pm,': 0.38; 'explain': 0.39; 'though,': 0.39; 'enough': 0.39; 'easy': 0.60; 'expression': 0.60; 'most': 0.60; 'effectively': 0.66; 'differences,': 0.84; 'subject:Proposal': 0.91; 'to:none': 0.92 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:cc :content-type; bh=o7KaMI85kfaVDJ1asn1RdOaWbcNyYBWL3BDk9n6Wy98=; b=Gnct3H4BOiFRhiLKn7bYUcTkuozvZcRt11WBBLwKTWOpjo+hqakbMzqRSMKQecOU9y vwfcHYPsUEhcXwagsai4kPJtl4ZGYGSjitLf0cpSJPexloFVYJJvV1P8nkRHUed1qShz Equ/RqHxL8ylT8b99IANquOU1M3HWtvjpHFYPqWdYCf2FjDg+a6dFzoprEIDIhC4cCCq KNergeLk7fS33nXN8PCbX8XwTEat35hHfBdUjxcjrPA0fZ6mkOqht8wAnF7mn43gexna cXVEGxZgGi4ziiZgxHA/Bgm6gSJ6T+5tPqrpB9Mv3gyVytqLFiQqGdhR1kQgzcgnVQTC xWOw== MIME-Version: 1.0 X-Received: by 10.69.25.69 with SMTP id io5mr28204584pbd.22.1396826181453; Sun, 06 Apr 2014 16:16:21 -0700 (PDT) In-Reply-To: <5341B56A.40004@gmail.com> References: <8084-1396540962-768613@sneakemail.com> <5341B56A.40004@gmail.com> Date: Mon, 7 Apr 2014 09:16:21 +1000 Subject: Re: Yet Another Switch-Case Syntax Proposal From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1396826189 news.xs4all.nl 2870 [2001:888:2000:d::a6]:60443 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69785 On Mon, Apr 7, 2014 at 6:13 AM, Michael Torrie wrote: > On 04/06/2014 12:07 PM, Chris Angelico wrote: >> This has a slight oddity of parsing (in that an expression can >> normally have a comparison in it); if you really want to use the >> result of a comparison inside a case block, you'd have to parenthesize >> it. But it's easy enough to explain to a human. > > This syntax is almost identical to the if/elif/else syntax, though, no? Like I said, it's a short-hand for an if/elif tree, nothing more. Most of the proposals have effectively been that anyway. There are differences, though; the case target gets evaluated only once, for instance. I'm not pushing strongly for its addition to the language. ChrisA