Python gets REAL Switch Case Statement

Python gets REAL Switch Case Statement

Christian Lempa

3 года назад

31,307 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

syumaK
syumaK - 16.05.2022 13:47

btw how did you get zsh working on your wsl?

Ответить
BlankPaper
BlankPaper - 10.02.2022 02:26

This is hardly a "switch:case" statement. The purpose of "switch:case" is speed of comparison and quick terminations. The issue with if/then, is simply horrible speed of checking each individual comparison with a "wide set match", which is exactly what the match:case is doing. They just hid the if/then tree and added an auto-terminate to them. So, it not only fails to work like EVERY switch:case in history... (including speed and function)... It is, at the core, still just a horrible, specific case use with no functional gains, might be right or not, hack.

The best solution is still to make your own with a simple DICT and a function. At-least it functions MORE like an actual switch:case, with literal comparisons, not close-enough-to-be-wrong comparisons. (Comparisons which might also NEED more coding to add MORE checking, since it is not "switching" to the next, to see if there is ALSO a match. Now you are back to nested loops and horrible matching, making it 10x worse than if:then statements.)

The current developers need to STOP developing and let the actual PROGRAMMERS determine what the PROGRAMMERS need in Python. As opposed to dictating what the programmers can have, because, "reasons"...

Ответить
Abid Zulqarnain
Abid Zulqarnain - 01.01.2022 07:43

Thanks

Ответить
Poop cat Gameplay
Poop cat Gameplay - 11.11.2021 16:32

when will python 3.10 come out?

Ответить
Bruno Davis
Bruno Davis - 10.11.2021 04:53

niceeeeee

Ответить
Cyrus King
Cyrus King - 16.10.2021 23:40

How is this still not avaliable? I tried the same "match string" code on Pycharm and it is not recognising it :((((

Ответить
Lucas Walters
Lucas Walters - 06.10.2021 00:56

Just learned about this new feature in the Python 3.10 official release docs and was curious about how to use it (Python is my first language); this is very informative, thank you! Also exciting that the new version is out officially

Ответить
Abdoul raouf Gambo
Abdoul raouf Gambo - 15.07.2021 10:05

WE need moreeeeeeeee😊😊😊😊

Ответить
Som Konor
Som Konor - 06.07.2021 22:10

When teachers show switch-case, the next thing they teach is that you should forget it. In my opinion, switch-case is more fragile and harder to debug than if-else, and it has got nothing to do with elegant way of coding, not to mention nested switch-case, which is nothing but nonsense.

Ответить
Shree Hari
Shree Hari - 27.05.2021 10:43

I always thought why the heck do we need break when we have specific cases for each command, no wonder python is used for AI, python is very smart, thank you for this tutorial hoping to see more

Ответить
marcello42
marcello42 - 07.05.2021 22:13

me googling how to do a switch statement in python.. realizing the most demanded language (to learn) doesn't have it.. guys...?

Ответить
SHONNER
SHONNER - 19.04.2021 05:15

I've have Switch in Python 2.5. So, someone has had to have written one for Python 3.x.

Ответить
Khalid Mohammad
Khalid Mohammad - 06.04.2021 21:44

No breaks Wohoo!

Ответить
Aleksandr Korshkov
Aleksandr Korshkov - 05.04.2021 16:51

Switch Case in python is much more than covered in this video.

Ответить
VocaloidSubsGerman
VocaloidSubsGerman - 28.03.2021 22:02

I think comparing this new feature to switch statements is strongly underselling it.
Besides just matching primitives, you can also use it to match class instances, dictionaries, lists, subfields of all of these and you can even extract partial data

Ответить
Eddie Zita
Eddie Zita - 25.03.2021 14:16

Whoa, python is getting sexy.

Ответить
PetritK
PetritK - 16.03.2021 16:03

I'm planning to learn Python, i know java, why case statement wasn't in python

Ответить
boris bob
boris bob - 11.03.2021 21:27

good new

Ответить
Dragonfly Code - Keven
Dragonfly Code - Keven - 11.03.2021 04:14

Well currently you can also get the "illusion" of a switch case statement in python by using a function and dictionary.

Ответить
Arnold
Arnold - 10.03.2021 05:13

Thumbs up. Techquikies for software!

Ответить
jeytis72
jeytis72 - 09.03.2021 11:22

Thanks Christian

Ответить