Re:Show HN: Rust-Like Traits in Python
by smitty1e on Sunday November 21, 2021 @08:16PM
(#29301605)
Just so. Yet, if there is interest in adding enough information to classes to support compile-time enforcement of interface requirements, ABCs to the rescue!
[ Parent
| on HN ]
Re:Show HN: Rust-Like Traits in Python
by actuallyalys on Sunday November 21, 2021 @11:44PM
(#29302841)
To clarify, mypy already has compile-time (well, static checker-time) enforcement of protocols (https://mypy.readthedocs.io/en/stable/protocols.html) and ABCs (https://mypy.readthedocs.io/en/stable/class_basics.html#abst...). Maybe that's what you meant? The first time I read your comment I interpreted as "if there is interest [on the part of core Python developers]".
Re:Show HN: Rust-Like Traits in Python
by BerislavLopac on Sunday November 21, 2021 @08:32PM
(#29301718)
The beauty of Python is that it supports both nominal subtyping (class hierarchies) and structural subtyping (protocols).