35
Type hinting in modern Python: The Protocol class
(codebeez.nl)
Welcome to the Python community on the programming.dev Lemmy instance!
Past
November 2023
October 2023
July 2023
August 2023
September 2023
Protocols are static duck typing. An object is a valid instance of protocol if it implements all the methods defined in the protocol, even if it doesn't declare it as implementing it. That last bit is important and the most distinguishing factor compared to an ABC.