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

Guido van Rossum guido at python.org
Wed Aug 20 17:53:02 CEST 2014


Was that meant to support Antoine's position (ABCs are not type
descriptions) or mine (they are)?


On Wed, Aug 20, 2014 at 4:27 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

>
> On 20 Aug 2014 10:14, "Guido van Rossum" <guido at python.org> wrote:
> >
> > 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.
>
> One of the ways I describe the explicit registration mechanism to people
> is as giving you the option of lying to the interpreter. If you use
> explicit registration, your registered type basically walks around with a
> sign saying "I'm a duck!" and the interpreter goes "OK, you're a duck!" and
> assumes it will be able to quack without actually checking in advance. It's
> really just a constrained version of normal duck typing, where the
> interpreter just assumes that *everything* may exhibit duck-like tendencies.
>
> Cheers,
> Nick.
>



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


More information about the Python-ideas mailing list