Article 5PS6F Hoyt: Structural pattern matching in Python 3.10

Hoyt: Structural pattern matching in Python 3.10

by
corbet
from LWN.net on (#5PS6F)
Ben Hoyt has published a criticaloverview of the Python 3.10 pattern-matching feature.

As shown above, there are cases where match reallyshines. But they are few and far between, mostly when handlingsyntax trees and writing parsers. A lot of code does haveif ... elif chains, but these are often eitherplain switch-on-value, where elif works almost as well, orthe conditions they're testing are a more complex combination oftests that don't fit into case patterns (unless you use awkwardcase _ if cond clauses, but that's strictly worse thanelif).

(Pattern matching has been covered here aswell).

External Content
Source RSS or Atom Feed
Feed Location http://lwn.net/headlines/rss
Feed Title LWN.net
Feed Link https://lwn.net/
Reply 0 comments