[Python-3000] Need help completing ABC pep

Talin talin at acm.org
Fri Apr 20 21:33:42 CEST 2007


Guido van Rossum wrote:
> I've started a PEP on Abstract Base Classes (ABCs), PEP 3119:
> 
>     http://www.python.org/dev/peps/pep-3119/
> 
> While I'm not ready yet to answer tough questions about this compared
> to alternative proposals, I *am* ready for feedback on the various
> open issues sprinkled throughout the current text, especially
> concerning decisions regarding exactly which operations to include in
> the various ABCs, and also regarding the level of detail required in
> the PEP.

One thing that I noticed is that you say "ABCs are not intrinsically 
incompatible with Interfaces", but you don't define what interfaces are.

I'm not sure my understanding of the interface proposals is correct, but 
here is what I would write based on my current understanding:

---

"Interfaces" in this context refers to a set of proposals for additional 
metadata elements attached to a class which are not part of the regular 
class hierarchy, but do allow for certain types of inheritance testing.

Such metadata would be designed, at least in some proposals, so as to be 
easily mutable by an application, allowing application writers to 
override the normal classification of an object.

The drawback to this idea of attaching mutable metadata to a class is 
that classes are shared state, and mutating them may lead to conflicts 
of intent. Additionally, the need to override the classification of an 
object can be done more cleanly using generic functions: In the simplest 
case, one can define a "category membership" generic function that 
simply returns False in the base implementation, and then provide 
overrides that return True for any classes of interest.

-- Talin


More information about the Python-3000 mailing list