Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Exploring Protocols in Python (Summary)

Now you know how to use protocols in Python. Protocols let you define a type relationship between objects without the burden of inheritance. This relationship is based on the internal structure of classes.

With protocols, you can perform structural subtyping or static duck typing using Python’s type hint system and external static type checkers, like mypy, Pyright, and Pyre.

Resources linked in this lesson:

In this video course, you’ve:

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

00:00 What a journey this has been. If you’ve reached this point by now and you didn’t skip any lessons, you should have a couple of new skills. Namely, you should now be able to explain what’s the point of protocols, why would you need them, and you should also be able to create and use your custom protocols in Python.

00:18 And then you’ll learn a couple more skills that build upon these two of course. You now know how to build generic protocols, and you know how to determine what members your protocols should have, which allows you to build and create flexible protocols that are suitable for a number of different situations.

00:38 You’ve also learned how to use inheritance with protocols, and you know that it’s different to implement a protocol implicitly versus to inherit from a protocol to create a subprotocol.

00:52 Now, if you want to learn more about protocols and the related and tangential concepts, you have two excellent tutorials you can refer to. The first one contains some of what you covered in this video course, but also other examples and even more content about protocols, and the second tutorial on Duck Typing in Python: Writing, Flexible and Decoupled code.

01:16 This will teach you more about the idea of duck typing, which is a fundamental idea in Python, and specifically for the existence of protocols. So I can highly recommend you check these two tutorials out.

01:29 Thank you so much for your time. My name is Rodrigo, and I will see you soon.

Become a Member to join the conversation.