How many languages features are available for OO support?

Gerhard Häring gh_pythonlist at gmx.de
Fri May 17 07:40:23 EDT 2002


* Byron Hammond <byronh at bigpond.net.au> [2002-05-17 11:02 +0000]:
> To what extent does Python support OO?
> 
> I know it has [multiple] inheritance and polymorphism etc, but to what
> extent does the language accomodate this and other OO concepts?

The language is described in the Python documentation. As you will see,
there are no abstract or interface keywords.

> Does Python support the notion of an abstract class or an interface
> through the use of language features?

No, not currently. Of course there are patters for newcomers from Java
to fake these features. But they're of little practical use, IMO.

Here's a quick shot from me:

class X:
    def __init__(self, *args, **kwargs):
        raise NotImplementedError, "This class is abstract :-P"

x = X()

> I ask this because not only do I want certain design decisions to be
> clear when reading the code, but I also want to make debugging easier
> for myself.

That's what comments and docstrings are for, like:

class X:
    """{short description here}
    Don't use this class directly. Subclass it
    and override the {methodname} method instead."""

Gerhard
-- 
This sig powered by Python!
Außentemperatur in München: 25.8 °C      Wind: 3.5 m/s





More information about the Python-list mailing list