ABCs
So Python 3000 will have abstract base classes.
As far as I know, in the Python world, an abstract base class used to mean, a base class that cannot be instantiated. Kind of like:
class Foo:
def __init__(self):
raise NotImplementedError, "Foo cannot be instantiated"
It would, however, be perfectly possible for an abstract base class to have valid, working methods, to be used by classes inheriting from Foo.
Apparently this isn't the case any longer. If I read PEP 3119 correctly, in Py3K-speak, an abstract base class is a way to trick isinstance() and issubclass() into believing that a given class derives from another class, when this actually isn't the case. For example:
>>> list.__bases__ (<class 'object'>,) >>> object.__bases__ ()
list derives from object, which in turn derives from nothing else. But:
>>> issubclass(list, collections.Sequence) True
In other words, list *pretends* to derive from Sequence, but it really doesn't, and so any methods defined in Sequence will not be inherited by list.
Filtered through my old-school-Python-riddled brain, this implies the following:
- abstract base classes mean something different now, and
- they break isinstance and issubclass, and
- methods defined in the ABC cannot be used by the "subclass".
Seriously, the more I read about Python 3.0, the harder it becomes for me not to be appalled. The language makes a heroic effort at fixing warts and problems and trimming fat, but at the same time it's becoming more and more complex.
I'd love to be proven wrong though. I like Python a lot, and I am (and have been) worried about what it's evolving into. But maybe Python 3.0 will actually be easy and intuitive to use, like the Python of old, and all the overly complex stuff will stay in the back rather than get in the way. I guess time will tell. (Or maybe I'm misunderstanding things... feel free to point that out. :-)
(This is mostly a matter of personal preference, of course -- for the last few years I've been gravitating toward languages with little syntax, that allow powerful new constructs to be written in the language itself. Think Scheme and Io. Python, however, has steadily been moving in the other direction.)