logoalt Hacker News

pinoy42002/20/20253 repliesview on HN

Pattern matching seems like a cool feature that was added just because it was cool. I think the syntax is really odd too - apparently to “be pythonic”. I really see no use for it other than to “look smart”. The fact that case match (switch case is a much better description) is expanded to practically a huge if else is disturbing. Similarly the walrus operator. Other than an answer to “what is a new feature of python that you like” interview trivia question, really, who has actually used it?


Replies

dragonwriter02/20/2025

I don't use pattern matching much, but I use walrus fairly regularly.

Qem02/20/2025

> Similarly the walrus operator. Other than an answer to “what is a new feature of python that you like” interview trivia question, really, who has actually used it?

At least in my case I use it all the time, to avoid duplicated operations inside comprehensions.

pansa202/20/2025

Yeah, it was added to tick the box for people who ask "does Python have pattern matching?"

If you look at the feature in detail, and especially how it clashes with the rest of the language, it's awful. For example:

https://x.com/brandon_rhodes/status/1360226108399099909

show 1 reply