What are 'Protocols' In Python? (Tutorial 2023)

preview_player
Показать описание
What are protocols in Python, and how can we use them in our code???

▶ Become job-ready with Python:

▶ Follow me on Instagram:

00:00 Intro
00:10 import Protocol
00:16 Python doesn’t care
00:41 Theory
01:46 Creating a Protocol
04:34 Using a Protocol
05:31 What’s the point?
07:18 Adding extras
07:49 Summing it up
Рекомендации по теме
Комментарии
Автор

Are you going to cover the comparison between ABC and protocol in future videos ? In my opinion, they do pretty much the same thing except one is checked before runtime, the other is checked during runtime

simonhuang
Автор

Thanks for the presentation! What is the advantage of this technique compared to using the ABC superclass with @abstractmethod decorators?

senayan
Автор

What is the advantage of using Protocol over a Printable ABC and then inheriting?
I didn't formerly know about Protocol, so thanks for teaching me something new, but I'm curious what the advantage is over the approach I would typically use.

vorpal
Автор

Hey, just wanted to drop a thank you ❤ Have been watching your videos lately and they are helping me master python.

Firetech
Автор

Thanks for sharing, very nice video! Keep it up 🔥

withpaul
Автор

so iiac it's no "implements" keyword and no explicit relation between interface and actual class, but the class must implement in code all required "requirements" from interface (protocol)

AlexCernat
Автор

The first minute was enlightening but then you made the fruit eat itself 😂

Finished the video

Wow, you're an incredible teacher.

Would love this approach on ABC
And the MVC architecture (framework agnostic)

chriskeo
Автор

That's very interesting. Can we simulate this behavior using an abstract class? What are the drawbacks and advantages of these different approaches? Show us how VSCode can provide hints to the user when implementing the subclasses.

Eltoncbraz
Автор

we are agreed that here the Book and Magazine classes don't inherit from Printable right ? that's the main point of the thing in my opinion, as like this we shouldn't deal with inheritance flaws like funky behavior when using super() or things like this

dragweb
Автор

This is nice to do with our code to make the codebase more robust ❤‍🔥

kunalsoni
Автор

Im guessing this just more lightweight way to use ABC that does not have runtime penalty? Even though i do not know if there is much penalty anyways

alexstone
Автор

pretty cool and may only help in the developer experience. may be suitable for a module or something but fairly useless in standalone programs. great video as always though :)

tfr
Автор

what extension do you use that shows how much usage a object has been used (eg. 1 usage, 2 usages, ...)?

link_safe
Автор

I might use this because when I use polymorphism I always mess something up

jamesmiller
Автор

If Banana inherits from Fruit then it would have the parent eat available to it. Not sure why an interface would be necessary there

erichstocker
Автор

For some reason, VSC is not generating warnings for this example.

miguelvasquez
Автор

is this similar to abstract base class?

rooftop
Автор

You did not make a tutorial about ABCs yet !!!

mista_ia
Автор

I don't know english can anyone help me learn english

mehmetsefa
Автор

I don't know, the whole object model from python it's so poorly designed, the lack of real encapsulation, proper decent type check at runtime, decent interfaces.... makes me laugh. Python will be the future PHP

codefields