Interface support in Python? (was Re: [Zope3-dev] Proposal: Improving on __implements__)

Jim Fulton jim@zope.com
Wed, 22 Jan 2003 14:04:11 -0500


Steve Alexander wrote:
> Hi folks,
> 
> I've added a new proposal to the zope3 development wiki.
> 
> It is called "Improving on __implements__'.
> 
> http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/BetterInterfaceImplements 
> 
> 
> 
> The main thing I'm proposing is to simplify the syntax for declaring 
> what interfaces are implemented by instances of a class and so forth.

I like Steve's proposal quite a bit.  I've made some minor comments
on it.

We'd have more options if we could add interfaces to Python.  Ironically,
some suggest (rightly) that we have fewer options because interfaces
might be added to Python and might cause new keywords to be created
that conflict with names we pick.

I would love to see interfaces added to Python, assuming that they
are substantially similar to what we have now.  I'm not optimistic that
it will ever happen.  I'm convinced that it won't happen if I'm the
only one advocating it because:

- It needs broad support for adoption, and

- I, frankly, don't have the patience for the sort of long
   drawn-out email discussion that this would require, especially if I
   have to participate by myself.

A while ago, Mike Pelletier, proposed syntax changes to Python to
support interfaces.  At the time, I thought Mike's proposal was
premature. Since then, we've had a lot more experience using
interfaces and I no longer feel Mike's proposal (or something like it)
is premature.  There have been a number of related proposals on
Python-Dev.

I think now would be a good time to make a new Python interfaces
PEP. Such a PEP should probably be a combination interface
and adapter PEP.  I'd be willing to work on this, but not alone.
Are other folks intereseted in working on this?

If we don't make a PEP, then I'm inclined to behave as if we
never will. Not that this is the last chance, but I don't want
to be encumbered by something that may never happen. If it does
happen, I'd be happy to deal with some refactoring then. :)

Jim

-- 
Jim Fulton           mailto:jim@zope.com       Python Powered!
CTO                  (888) 344-4332            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org