An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
The NEW Match-Case Statement in Python 3.10
Python 3.10 is beginning to fill out with plenty of fascinating new features. One of those, in particular, caught my attention-structural pattern matching-or as most of us will know it, switch/case statements.
Switch-statements have been absent from Python despite being a common feature of most languages.
Back in 2006, PEP 3103 was raised, recommending the implementation of a switch-case statement. However, after a poll at PyCon 2007 received no support for the feature, the Python devs dropped it.
Fast-forward to 2020, and Guido van Rossum, the creator of Python, committed the first documentation showing the new switch-statements, which have been named Structural Pattern Matching, as found in PEP 634.
Python switch-statements are not just switch-statements, they are much more powerful thanks to their structural pattern matching capabilities.
Let's take a look at how this new logic works.
Original Link: https://dev.to/jamescalam/the-new-match-case-statement-in-python-3-10-23ij
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To