Skip to content

Update design FAQ 'switch' entry mention of match-case. #111307

Closed
@dascritch

Description

@dascritch

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:

  1. Go to https://docs.python.org/3.12/faq/design.html
  2. Click on Why isn’t there a switch or case statement in Python?
  3. match case isn't cited, but the catastrophic elif 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 !

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12bugs and security fixes3.13bugs and security fixesdocsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions