DEV Community

Discussion on: Python Switches to Match-Case

Collapse
 
gjorgivarelov profile image
gjorgivarelov • Edited

I am probably missing something but:
dog_name=input(...)
and then later in the "case" statement:
case True:
print("Go get it!", name)
Isn't it supposed to be "dog_name" instead of "name"?

And why were PEP people so hesitant with introducing the match-case feature?

Collapse
 
chorcon profile image
Chorcon

I don't think you're missing anything here, you're spot on. My guess is they changed from 'name' to 'dog_name' for clarity, then the author probably forgot to update it later in the code.

Collapse
 
vickilanger profile image
Vicki Langer

You are absolutely correct! I have since fixed the undefined variables.

Collapse
 
vickilanger profile image
Vicki Langer

Eek. Thanks for pointing that out. I fixed the messed up naming.

I can't speculate as to why it took so long to add a match-case. I do know in PEP 3103, they claimed there was no support for such a feature. Then, PEP 635 includes rationale and some history of pattern matching. Honestly though, none of this really answers your question. These are all the official answers. I was hoping to find something more informal.