A Closer Look At Structural Pattern Matching // New In Python 3.10!

A Closer Look At Structural Pattern Matching // New In Python 3.10!

ArjanCodes

3 года назад

101,602 Просмотров

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


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

ArjanCodes
ArjanCodes - 09.07.2021 18:16

Too bad my camera decided to switch off near the end. It probably couldn't handle the awesomeness of structural pattern matching 😎.

Ответить
Timothy Quinn
Timothy Quinn - 30.10.2023 20:25

Great video. One huge opportunity is to follow the functional programming patterns of returning tuples of values from functions and matching results. Eg. function `def do_foo()` returns (ok: bool, reason: str, data: dict) . By using structural pattern matching you can write cleaner and intuitive invocation code. Once I get my code base moved up to 3.10+, I'll be using this heavily. T hanks for the great videos!

Ответить
Joao Pedro Rocha
Joao Pedro Rocha - 26.09.2023 00:21

Neat!

Ответить
Not Sure
Not Sure - 18.06.2023 16:11

cool video thx, maybe a side by side comparison of the 3.10 and the previous version would be nice.

Ответить
The Immortal Sun-kun
The Immortal Sun-kun - 16.05.2023 16:27

Fantastic video!

Ответить
Lone F
Lone F - 11.05.2023 14:15

Watering your flower

Ответить
SP
SP - 16.03.2023 13:28

Best tutorials on Structural pattern matching....
Thanks 🙏🙏🙏
After this tut, dev will use it for complex it-else,
Waiting for V2 of it, with regex & using async task group on functions part of each case

Ответить
Tony
Tony - 21.01.2023 10:58

Thanks!

Ответить
Tony
Tony - 21.01.2023 10:57

what a great implementation of the classical Switch statement offering much versatility. As i am not a big fan of the argparse module, this certainly makes my life easier in the future.

Ответить
xpmon
xpmon - 17.12.2022 05:07

Can you match by type and tuple, sorta like Scala's match?

Ответить
PrimalVision
PrimalVision - 12.11.2022 05:46

Great content. Very helpful for new Python programmers.

Ответить
Chris Weldon
Chris Weldon - 09.10.2022 14:59

I have learned more from 10 arjan videos that i have from any other source on python. another great video this.

Ответить
Airat Valiullin
Airat Valiullin - 23.09.2022 17:12

Actually, you don't need to import typing List and use more convenient and beginner-friendly 'list[int]' syntax!

Ответить
Tomás Bernardo
Tomás Bernardo - 04.09.2022 23:46

In the first example why did you use the ! in the "other" case?

Ответить
baphnie
baphnie - 23.08.2022 16:52

Can someone explain how the pipe character is used in python? It seems like Arjan is using it here as a logical OR, but I can't seem to get that functionality out of it in other settings.

Ответить
Zach Kramer
Zach Kramer - 23.08.2022 03:38

Can this be used for factory pattern?

Ответить
N
N - 02.08.2022 21:05

Very nice feature. Thank you

Ответить
Vidar
Vidar - 25.07.2022 16:10

What does the !r do in the string interpolation?

Ответить
Tim Rowe
Tim Rowe - 21.07.2022 03:38

What's that "other!r"? I don't recognise that use of the exclamation mark or what the r does.

Ответить
Iraj
Iraj - 30.06.2022 07:05

great job Arjan

Ответить
Manuel Ochoa
Manuel Ochoa - 26.06.2022 01:06

¡Gracias!

Ответить
E W
E W - 21.06.2022 17:28

Nice video. Don't you think adding OOP in the "run_command_v4 function is a bit overkill?

Ответить
Andrea Ardemagni
Andrea Ardemagni - 10.06.2022 17:50

Hi! I have just been introduced to your channel and I wanted to ask - how shall I navigate your videos from more like beginner level to advanced? Do you actually have videos for python beginners? Thank you!

Ответить
Julian
Julian - 30.05.2022 15:07

patten matching before fixing recursion? meh

Ответить
imadetheuniverse4fun
imadetheuniverse4fun - 26.05.2022 20:09

Very interesting. For the object pattern matching, is it actually instantiating a new object for every case check? Wondering whether this would have performance implications for classes with expensive constructors.

Ответить
Suchi Gate
Suchi Gate - 05.05.2022 16:56

what is difference between using IF/ELIF and case?

Ответить
Patrick Tarnaud
Patrick Tarnaud - 24.04.2022 21:25

your videos are always very interesting. thank you !

Ответить
Asa Stallard
Asa Stallard - 20.04.2022 23:08

In v4, why did you use command as the variable for the match statement along with command being an element of the Command class? Doesn't overuse of the word command like that muddy the water for anyone reading it?

Ответить
torrentails
torrentails - 10.04.2022 18:55

Camera accidentally switches off
Arjan: Sorry for the camera, I'll try to put a positive spin on it.
Me: Finally! Me and my ADHD brain can actually focus on the code being written, instead of constantly getting distracted!

Ответить
jon
jon - 31.03.2022 12:46

Wished I have this channel so much earlier in my career!!

Ответить
⛤ Obed 
⛤ Obed  - 29.03.2022 22:07

Neat! One more question please, i think you didn’t said it explicitly; okay the case has an order importance, but if i dont qui the program as you do with quit() , may i go by many case or only one is possible as the elif statement ? Thanks i hope i could currently use python 3.10 its dope!

Ответить
Franco Minucci
Franco Minucci - 24.03.2022 17:47

Please, tell me you can implement duff's device in Python! XD

Ответить
Mithun Kinarullathil
Mithun Kinarullathil - 12.02.2022 02:56

Great tutorial @arjan. One question. In your first example, you used None to mention the return type of the methods without any return. Is this the standard/preferred way? I don't really mention it if there is no return. Thank you.

Ответить
Doug Steel
Doug Steel - 10.02.2022 01:47

Given how slow python execution, other than compiled libraries is, is there much point optimising it? Is it just a glorified launch platform for C++ code? It is beyond my imagination why it's become the go-to for tensor processing, it makes no sense. Perhaps it's indicative of an even starker divide between people that program for the machine and people who just want predetermined things immediately

Ответить
Lufi Porndre
Lufi Porndre - 24.01.2022 19:15

Switch statement in python 🤔?
Can't we do the same with dictionary

Ответить
Mateusz Bagiński
Mateusz Bagiński - 13.01.2022 20:46

Thanks, man! Very clearly explained!

Ответить
Tekay37
Tekay37 - 09.01.2022 01:28

I've learned that switch/case statements have their place in factory methods where different inputs lead to the creation of different classes. I think that's where this tool might become useful as well because you don't depend on switching over a primitive value like a string or an int.

Ответить
WeisSchwarz
WeisSchwarz - 06.01.2022 07:14

I'm pretty new to this channel. Is that some inside joke you put on the wall (STRUCTURAL MATTER PATCHING)?

Ответить
Luis Miguel
Luis Miguel - 18.12.2021 16:17

Switch case in python is something that I've been waiting for so long. Your tutorials are amazing by the way.

Ответить
John Edge
John Edge - 21.11.2021 18:22

Question. at 9m34 looking at version 3 of the command. Comparing the "with --force" case with the "no force", the print statements are different, but the next command is quit() in both cases. Not seeing how the behaviour will actually be different.

Ответить
Zacky
Zacky - 30.10.2021 13:22

The best structural pattern matching tutorial I've watched.

Ответить
Preslav Rachev
Preslav Rachev - 18.10.2021 17:18

Structural Matter Patching

Ответить
CodingInPython-OSRS
CodingInPython-OSRS - 15.10.2021 00:42

Is this the new best way to keep track of states in an application?

Ответить
Admir Memic
Admir Memic - 12.10.2021 23:49

Learned Scala 5ish years ago and starred working with it, since then I get deja vu every time I see a new feature of another language being released.

Ответить