Closed
Description
Documentation
Describe the bug
I did a search to remember what was the switch
keyword in Python, and the very first link I got is a not up-to-date page from Python 3.11 documentation, explaining that elif
is great.
To Reproduce
Steps to reproduce the behavior:
- Go to https://docs.python.org/3.12/faq/design.html
- Click on Why isn’t there a switch or case statement in Python?
match case
isn't cited, but the catastrophicelif
cascade is still the “reference”
Expected behavior
Correct it and explain why match case
is a really better coding practice instead of cascaded elif
(unreadable, unmaintainable, confuse)
Sidenote :
Found here what I was looking at.
Even on this not related page the author use return
, and didn't think to replace elif
with simplier if
!