[Python-ideas] Optional Static Typing -- the Python Way
Andrew Barnert
abarnert at yahoo.com
Thu Aug 21 17:46:46 CEST 2014
On Aug 21, 2014, at 7:30, Brett Cannon <brett at python.org> wrote:
> 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. =)
Cute, but it seems like it actually impedes the reading of "x is an Iterable". (Although I guess as compensation you get "x is an Integer" if you import numbers as n, and you get to yodel like Adam Ant when reading code about file types.)
More seriously: I argued along the same lines as you as to the advantages of using the ABCs directly, but I understand the opposing viewpoint: although static type hints and runtime type constraints are _normally_ the same things, they're not _necessarily_ so, and forcing them to share a representation may preclude some of the fancy things people want to do with types beyond the simple generic model (e.g.; the PyConstraints sub-thread).
More information about the Python-ideas
mailing list