Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate (or modify) switch.py #39

Open
C-Ezra-M opened this issue Sep 14, 2022 · 1 comment
Open

Deprecate (or modify) switch.py #39

C-Ezra-M opened this issue Sep 14, 2022 · 1 comment

Comments

@C-Ezra-M
Copy link

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.

@aroberge
Copy link
Owner

The examples included in this repository are just that: examples. They are meant to demonstrate what is possible to do with ideas. So, I do not plan to deprecate any examples - especially since they work with Python 3.6.

Modifying it so that it does not conflict with the match statement is likely a good idea. If you want to submit a PR that does just that, you are more than welcome. :-) Otherwise, I'll eventually do it myself, but this is not a high priority for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants