[Python-Dev] PEP 544: Protocols
Matthias Kramm
kramm at google.com
Mon Mar 20 17:11:54 EDT 2017
I'm a big fan of this. I really want structural subtyping for
http://github.com/google/pytype.
On Mon, Mar 20, 2017 at 5:00 AM, Ivan Levkivskyi <levkivskyi at gmail.com>
wrote:
> Explicitly declaring implementation
> -----------------------------------
>
> To explicitly declare that a certain class implements the given protocols,
>
Why is this necessary? The whole point of ducktyping is that you *don't*
have to declare what you implement.
I get that it looks convenient to have your protocol A also supply some of
the methods you'd expect classes of type A to have. But completing an
implementation in that way should be done explicitly (via including a
utility class or using a decorator like functools.total_ordering), not as
side-effect of an (unnecessary) protocol declaration.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170320/32ab6833/attachment.html>
More information about the Python-Dev
mailing list