[Python-ideas] Optional Static Typing -- the Python Way

Antoine Pitrou antoine at python.org
Fri Aug 22 16:36:26 CEST 2014


Le 22/08/2014 08:53, Brett Cannon a écrit :
>      > 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.
>
>
> You're reading that too literally as code and not as a descriptive
> sentence. What I meant to convey is that code `def foo(x: a.Mapping)`
> can be read in your inner voice as "function foo has a parameter x which
> is a.Mapping", where "a.Mapping" somewhat reads like "a Mapping".

So? That would be true with anything else that isn't an ABC, as long as 
you import the relevant module with the name "a" (which is silly, but 
hey :-)).

   def foo(x: a.List(a.Number)) -> a.Number

Regards

Antoine.




More information about the Python-ideas mailing list