[Python-3000] PEP 3119 - Introducing Abstract Base Classes
Jim Jewett
jimjjewett at gmail.com
Fri Apr 27 19:10:24 CEST 2007
On 4/27/07, Barry Warsaw <barry at python.org> wrote:
> - - Attributes. Interfaces allow you to make assertions about
> attributes, not just methods, while ABCs necessarily cover only methods.
Why can't they have data attributes as well?
> - - With interfaces, you can make assertions about individual objects
> which may be different than what their classes assert. Interface
> proponents seem to care a lot about this and it seems there are valid
> uses cases for it.
Isn't this something that could be handled by overriding isinstance?
> Another example of separating inheritance and interface comes up when
> you want to derive a subclass to share implementation details, but
> you want to subtly change the semantics, which would invalidate an
> ABC claim by the base class. Something like a GrowOnlyDictionary
> that derived from dict for implementation purposes, but didn't want
> to implement __delitem__ as required by the MutableMapping ABC.
OK, that makes the isubclass override trickier, so there should be an
example, but I think it can still be done.
> Finally, I'm concerned with the "weight" of adding ABCs to all the
> built-in types.
What if the builtin types did not initially derive from any ABC, but
were added (through an issubclass override) when the abc module was
imported?
-jJ
More information about the Python-3000
mailing list