On Tue, May 18, 2021 at 8:26 PM Ir. Robert Vanden Eynde <robertv...@gmail.com> wrote: > About matching, switch case does not exist in python because if/elif/else > cascade exists > > if (x := 5) in irange(1, 5): > println(stuff1) > elif x == 8 > println(stuff2) > else: > println(stuff3) >
Hmm, switch statements exist in a lot of other languages that also have if/elif/else. A closer comparison, for a lot of switch blocks, is a dispatch table based on a dictionary. For more complex switching, there's the concept of pattern matching, which has been debated on-and-off for a good while, and is now being added to the language; but the main reason for not needing a classic switch block is probably the dict lookup option. ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/QKEYPXJR6CNKY2TOXJ66TAP46HWLF5YL/ Code of Conduct: http://python.org/psf/codeofconduct/