Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

match/case statement raises SyntaxError in PyCharm

I’d like to use the match/case statement but currently PyCharm does not like it and when I try to run this code:

def test(action):
    match action:
        case "send":
            pass
        case "create":
            pass
        case "dump":
            pass

it tells me

    match action:
          ^
SyntaxError: invalid syntax

I use python 3.9.1 and PyCharm 2021.2.3 Pro. The keywords match and case are blue so I guess PyCharm recognizes them but is not able to run it. What am I missing here?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You are using Python version less than 3.10.

PEP 634: Structural Pattern Matching is introduced in python 3.10. See What’s New In Python 3.10
for more information.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading