Skip to content

Deprecate (or modify) switch.py #39

Description

@C-Ezra-M

switch.py should be deprecated, or at least modified because of match statements that debuted in 3.10.6.

Relevant PEPs:

match statements look like this:

from random import randint
match randint(0, 10):
  case 0 | 1 | 2 | 3:
    print("Terrible!")
  case 4:
    print("My favorite number!")
  case 5 | 6:
    print("Average.")
  case 7 | 8:
    print("Good!")
  case 9 | 10:
    print("Terrific!")
  case _: # default
    print("Uh oh, something has happened.")

My idea is to introduce default: as an alias of case _: (which also means disallowing default from being an identifier). If reserving default is not an option, just use else.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions