Комментарии:
btw how did you get zsh working on your wsl?
Ответить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"...
Thanks
Ответитьwhen will python 3.10 come out?
Ответитьniceeeeee
ОтветитьHow is this still not avaliable? I tried the same "match string" code on Pycharm and it is not recognising it :((((
Ответить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
ОтветитьWE need moreeeeeeeee😊😊😊😊
Ответить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.
Ответить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
Ответитьme googling how to do a switch statement in python.. realizing the most demanded language (to learn) doesn't have it.. guys...?
ОтветитьI've have Switch in Python 2.5. So, someone has had to have written one for Python 3.x.
ОтветитьNo breaks Wohoo!
ОтветитьSwitch Case in python is much more than covered in this video.
Ответить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
Whoa, python is getting sexy.
ОтветитьI'm planning to learn Python, i know java, why case statement wasn't in python
Ответитьgood new
ОтветитьWell currently you can also get the "illusion" of a switch case statement in python by using a function and dictionary.
ОтветитьThumbs up. Techquikies for software!
ОтветитьThanks Christian
Ответить