(original) (raw)

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@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.