[Python-Dev] Type hints -- a mediocre programmer's reaction

Arnaud Delobelle arnodel at gmail.com
Tue Apr 21 11:56:07 CEST 2015


On Tue, 21 Apr 2015 at 09:59 Cory Benfield <cory at lukasa.co.uk> wrote:
[...]

> Further, Python's type system is not sufficiently flexible to allow
> library authors to adequately specify the types their code actually
> works on. I need to be able to talk about interfaces, because
> interfaces are the contract around which APIs are build in Python, but
> I cannot do that with this system in a way that makes any sense at
> all. To even begin to be useful for library authors this PEP would
> need to allow some kind of type hierarchy that is *not* defined by
> inheritance, but instead by interfaces. We've been discouraging use of
> 'type' and 'isinstance' for years because they break duck typing, but
> that has *nothing* on what this PEP appears to do to duck typing.
>
> This is why I feel like this PEP may be a real threat to duck typing.  If
people constantly get told by their editor / IDE that they are calling
function with the wrong argument types, what are they going to do?  They
may start adopting the same approach as in Java / C++ etc... where
interfaces must be explicitly defined and the practice of duck typing may
become forgotten because discouraged by the tools programmers use.

I guess what I'm saying is that this could encourage a very significant
cultural change in the way Python code is written towards a less flexible
mindset.

-- 
Arnaud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150421/f1428e06/attachment.html>


More information about the Python-Dev mailing list