OOP & Abstract Classes

alex23 wuwei23 at gmail.com
Mon May 11 23:13:02 EDT 2009


On May 12, 1:22 am, Mike Driscoll <kyoso... at gmail.com> wrote:
> I've never used (or heard of) the Abstract type...and the guy who
> wrote the FAQ was being a jerk. It looks like he was just throwing in
> an undefined variable name just to make his Python program break while
> taking a pot shot at people who use that sort of thing. Whatever.

The IAQ's entry on Abstract classes predates the introduction of
Abstract Base Classes to Python 2.6/3.0. Rather than being a "jerk",
the example shows how to produce similar behaviour without code AS
WELL as demonstrating a more extended approach. (You're not breaking
your program if the behaviour is intentional...)

> Hopefully someone who has used Abstract classes will jump in here and
> give you more information about whether or not they matter in Python.

Abstract classes are one mechanism for defining interfaces, but as
we've covered it's not the only approach that can be taken. I've
always been happy defining abstract methods using 'raise
NotImplementedError', but clearly the ABC approach is perceived as
having value otherwise it would never have been introduced into
2.6/3.0.



More information about the Python-list mailing list