logoalt Hacker News

macintux • 11/07/2024 • 1 reply • view on HN

I mostly ignored Python until my job required it, about 8 years ago. Coming from Erlang, I was pleasantly astonished to find that I could use tuple pattern matching in function headers… until I discovered that was dropped in Python 3 and I had been using the mostly-dead version 2 runtime.


Replies

harrisi • 11/07/2024

I think I'd call this destructuring, as opposed to patterns and matches, and Python still does it, just not in the function head.

I do wish they went the opposite direction and made the feature better instead of keeping it as a weird assignment thing in the body. The match statement is a similarly unfortunate solution, in my opinion.

Oh well. :)

➕ show 1 reply