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

Guido van Rossum guido at python.org
Wed Aug 20 02:12:54 CEST 2014


On Tue, Aug 19, 2014 at 4:02 PM, Antoine Pitrou <antoine at python.org> wrote:

> Le 19/08/2014 18:50, Terry Reedy a écrit :
>
>  On 8/19/2014 9:27 AM, Nick Coghlan wrote:
>>
>> What I like: 'optional type hints' based on a fleshed-out ABC systems
>> that collects all ABCs together on one module via import from current
>> files. It seems that we have been slowly groping towards this for years.
>>
>
> Hmm, I've been saying this already, but my intuition is that it's a bad
> idea to conflate *type descriptions* (what this proposal is about) and
> actual *runtime types* (what ABCs are).
>

But are they? I think the registration mechanism makes it clear that they
aren't (necessarily) runtime types -- by linking a concrete type with an
ABC through registration you are pretty clearly stating that the ABC
*describes* (an aspect of) the concrete class without automatically adding
any behavior from the ABC to it.


> Besides, the fact that type descriptions must be parametrable, and
> therefore end up being used as instances, sounds like it kills the idea of
> making them regular (runtime) types as well. Unless we make them
> metaclasses?
>

No, that doesn't follow at all. The concept of metaclasses means that
classes *are* instances (of the metaclass) and it lets us define operations
(in particular __getitem__ :-) on the classes.

(I was going to show a working example, but I ran out of time, and I'm
taking a vacation the rest of this week.)

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140819/fcfe482f/attachment-0001.html>


More information about the Python-ideas mailing list