[Python-ideas] Optional Static Typing -- the Python Way
Antoine Pitrou
antoine at python.org
Thu Aug 21 16:54:17 CEST 2014
Le 21/08/2014 10:30, Brett Cannon a écrit :
>
> Isn't that the magic of __instancecheck__/__subclasscheck__? If
> typing.py does the right thing here then it shouldn't matter.
What is "the right thing"?
> You could
> use __init__ or __getitem__ to construct an object who upon
> introspection provides the details you want and do what you expect, and
> then override the appropriate methods so that isinstance() checks check
> against the ABC instead of the type class itself (heck we could make the
> base type class require that you inherit from an ABC to promote working
> with ABCs instead of concrete classes).
So we agree that type descriptions should be separate things from ABCs,
or not?
> I have to also say that I like using ABCs because `from collections
> import abc as a` leads to reading parameters like "x is a.Mapping" which
> is linguistically quaint. =)
Except that "x is a.Mapping" is False with a normal Python.
Regards
Antoine.
More information about the Python-ideas
mailing list