TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Pattern Matching in Python

37 pointsby amossonover 4 years ago

3 comments

ggmover 4 years ago
Always wanted a switch coding style. Now, offered one i am having second thoughts introspecting if my code improves for readability if I use one. I think on balance yes. I&#x27;ve always like this approach to a single value or expression gating choices.<p>Also wondering about the degenerate forms of fall through alternates, so it&#x27;s a stack of code optionally run.<p>There is another link to c code switches and duffs device in hn recently
评论 #24847849 未加载
singhracover 4 years ago
Wow I love this. This is one of my favorite features of Rust&#x2F;OCaml (along with variant types &#x2F; data-bearing-enums).<p>I think the latter would help a lot with error handling in particular, not to mention defining protocols.
pansa2over 4 years ago
See also the PEPs: <a href="https:&#x2F;&#x2F;www.python.org&#x2F;dev&#x2F;peps&#x2F;pep-0634&#x2F;#abstract" rel="nofollow">https:&#x2F;&#x2F;www.python.org&#x2F;dev&#x2F;peps&#x2F;pep-0634&#x2F;#abstract</a>