[Python-ideas] Structural type checking for PEP 484

Brendan Barnwell brenbarn at brenbarn.net
Thu Sep 10 03:50:42 CEST 2015

On 2015-09-09 13:17, Guido van Rossum wrote:
> Jukka wrote up a proposal for structural subtyping. It's pretty good.
> Please discuss.
> https://github.com/ambv/typehinting/issues/11#issuecomment-138133867

	I'm not totally hip to all the latest typing developments, but I'm not 
sure I fully understand the benefit of this protocol concept.  At the 
beginning it says that classes have to be explicitly marked to support 
these protocols.  But why is that?  Doesn't the existing 
__subclasshook__ already allow an ABC to use any criteria it likes to 
determine if a given class is considered a subclass?  So couldn't ABCs 
like the ones we already have inspect the type annotations and decide a 
class "counts" as an iterable (or whatever) if it defines the right 
methods with the right type hints?

Brendan Barnwell
"Do not follow where the path may lead.  Go, instead, where there is no 
path, and leave a trail."
    --author unknown

More information about the Python-ideas mailing list