The new Python match
Conclusion
The match
statement included with Python 3.10 is slated to be release in October 2021. As you can see from the few examples I explored here, it can streamline a number of tasks and eliminate many, many if
/elif
blocks. If you start learning this new syntax now, you'll be well on your way to even more functional Python code as soon as this release becomes official!
Infos
- Python: http://www.python.org
- Python PEP 622 original match proposal: https://www.python.org/dev/peps/pep-0622/
- Python PEP 634 (replaces PEP 622): https://www.python.org/dev/peps/pep-0634/
- Code for this article: ftp://ftp.linux-magazine.com/pub/listings/linux-magazine.com/249/
- Python 3.10 alpha: https://www.python.org/downloads/release/python-3100a6/
« Previous 1 2 3 4
Buy this article as PDF
Express-Checkout as PDF
Price $2.95
(incl. VAT)
(incl. VAT)