About 53 results
Open links in new tab
  1. What is the Python equivalent for a case/switch statement?

    Jul 14, 2012 · Python 3.10.0 provides an official syntactic equivalent, making the submitted answers not the optimal solutions anymore! In this SO post I try to cover everything you might want to know about …

  2. Replacements for switch statement in Python? - Stack Overflow

    Sep 13, 2008 · 2244 Python 3.10 (2021) introduced the match - case statement, which provides a first-class implementation of a "switch" for Python. For example:

  3. Есть ли в Python оператор switch case? - Stack Overflow на русском

    Столкнулся с тем, что требуется реализовать множественное условие, которое в других языках я бы реализовал с помощью конструкции switch-case. В Python мне приходится расписывать всё …

  4. python - Match case statement with multiple 'or' conditions in each ...

    Dec 2, 2022 · Is there a way to assess whether a case statement variable is inside a particular list? We have three lists: a = [1, 2, 3] b = [4, 5, 6] c = [7, 8, 9] Then I want to check whether x is in each list.

  5. How to use multiple cases in Match (switch in other languages) cases in ...

    Oct 20, 2021 · I am trying to use multiple cases in a function similar to the one shown below so that I can be able to execute multiple cases using match cases in python 3.10 def sayHi(name): match name: ...

  6. Конструкция match-case в Python 3.10 - Stack Overflow на ...

    4.10.2021 выпущен офрелиз Python 3.10. В числе прочих обновлений была предоставлена возможность использования конструкции match-case, которая носит название структурное …

  7. python - How to use values stored in variables as case patterns ...

    Although, given how python is trying to implement pattern-matching, I think that for situations like this it's probably safer and clearer code to just use an if/elif/else tower when checking against constant values.

  8. python - How to create a switch case with the cases being intervals ...

    I'd like to create a switch/case where the cases can have intervals as condition, like: switch = { 1..<21: do one stuff, 21...31: do another } How can I achieve this result?

  9. python - Swicth case en python3 - Stack Overflow en español

    Quisiera saber como puedo implementarlo en python, y quisiera saber si en los switch case se puede tener varias cosas dentro de cada caso llamando a varios def.

  10. python - Continue to match next case after match? - Stack Overflow

    Feb 28, 2023 · According to the official Python documentation (PEP 636), once the first matching pattern is found, the body of that case is executed, and all further cases are ignored. Therefore, C-style fall …