3 ms·
I've recently found about Protocol / structural subtyping in Python and found this sort of pattern really useful as duck typing is so common in py code. Highly
by carlosf 6y ago
I've recently found about Protocol / structural subtyping in Python and found this sort of pattern really useful as duck typing is so common in py code.
Highly recommend reading:
https://www.python.org/dev/peps/pep-0544/ https://www.python.org/dev/peps/pep-0544/
https://docs.python.org/3/library/typing.html#nominal-vs-structural-subtyping https://docs.python.org/3/library/typing.html#nominal-vs-str...
https://docs.python.org/3/library/typing.html#typing.Protocol https://docs.python.org/3/library/typing.html#typing.Protoco...
Cool example:
https://github.com/jordaneremieff/mangum/blob/main/mangum/types.py https://github.com/jordaneremieff/mangum/blob/main/mangum/ty...