[Python-ideas] Match statement brainstorm
Ethan Furman
ethan at stoneleaf.us
Wed May 25 23:50:13 EDT 2016
On 05/25/2016 07:59 PM, Chris Angelico wrote:
> On Thu, May 26, 2016 at 12:34 PM, Stephen J. Turnbull wrote:
>> Leaving aside the spelling quibbles, following "if" I would "see"
>> "matches" as an operator, and want to write
>>
>> if <thing> matches <matcher>:
>> pass
>> elif <thing> matches <matcher>:
>> pass
>>
>> and I'm back in "if ... elif ... else ..." land.
>
> What if it were like this:
>
> if <thing> ...:
> matches <matcher>:
> pass
> matches <matcher>:
> pass
>
> with a colon at the end of the first line too?
I would just as soon use the switch/case keywords, with extra matching
oomph. It doesn't have to match C(-like) exactly, and would be
immediately recognizable as to the intent (following tests are against
the thing in the switch portion).
I think it's okay to put our own Python spin on it.
--
~Ethan~
More information about the Python-ideas
mailing list