Yet Another Switch-Case Syntax Proposal

Chris Angelico rosuav at gmail.com
Sun Apr 6 19:16:21 EDT 2014


On Mon, Apr 7, 2014 at 6:13 AM, Michael Torrie <torriem at gmail.com> 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



More information about the Python-list mailing list