About 52 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. 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.

  3. How to do an else (default) in match-case? - Stack Overflow

    Aug 16, 2021 · 80 Python recently has released match-case in version 3.10. The question is how can we do a default case in Python? I can do if/elif but don't know how to do else. Below is the code:

  4. Python: match/case by type of value - Stack Overflow

    May 18, 2022 · I came across a weird issue while using the new match/case syntax in Python3.10. The following example seems like it should work, but throws an error: values = [ 1, "hello", T...

  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. 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.

  7. python - Conditional statement inside a match case - Stack Overflow

    Apr 14, 2022 · Is it possible to have a conditional statement as a case for a match statement in Python? Working something like this: test = 'Aston Martin' makes = ['Aston Martin', 'Bentley'] match test: cas...

  8. python - How to use match case with a class type - Stack Overflow

    Mar 11, 2022 · I want to use match to determine an action to perform based on a class type. I cannot seem to figure out how to do it. I know their are other ways of achieving this, I would just like to know …

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

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

  10. Python Match Case (Switch) Performance - Stack Overflow

    Jul 21, 2021 · A while back, I published an article on Medium about Python's match-case performance, analyzing the generated byte code and performing benchmarks and comparisons.