[Python-ideas] A proper way to bring real interfaces to Python

Serge Matveenko s at matveenko.ru
Mon May 6 03:22:17 EDT 2019


On Sun, May 5, 2019 at 8:23 PM Stephen J. Turnbull
<turnbull.stephen.fw at u.tsukuba.ac.jp> wrote:
>
> Serge Matveenko writes:
>
>  > So, I would like to propose adding a third main object called
>  > `interface` in addition to `object` and `type` and to use it to define
>  > interface objects. Such interfaces could then be used in the class
>  > definition in the following way.
>
> How does this compare to existing technology such as zope.interface?
> Why do you want it to behave differently where it does?

`zope.interface` has a lot of functionality that is true. However, it
is just another hacky way to bring interfaces functionality to a
project. My proposal is to finally bring interfaces to Python.

I've provided a POC for the idea. I agree that while my POC could be
usable in real life projects it lacks some functionality of
`zope.interfaces`. However, bringing the basic but strict interface
support to Python could greatly benefit to projects like
`zope.interface` as it would allow developers to write more reusable
code using core Python functionality when it suits their need and
rarely depend on external libraries when they need some extra
features.

Also, `strict-interfaces` provides typing annotations support and
could be easily be adopted in conjunction with PEP 544.


More information about the Python-ideas mailing list