AI engineering glossary · Python advanced
What is protocol?
Protocol (also called Structural subtyping): A typing feature that defines an interface by the methods an object has, so any class with them is accepted without inheriting. It brings duck typing into static checking and is called structural subtyping.
Protocol: an example
class Readable(Protocol): def read(self) -> str: ... accepts any object with a matching read method.
Related terms
More Python advanced terms
Where you learn it
Protocol is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.