Question about subclassing - version 2
Maric Michaud
maric at aristote.info
Fri Sep 8 06:12:39 EDT 2006
Le vendredi 08 septembre 2006 09:51, bearophileHUGS at lycos.com a écrit :
> Frank Millman, just a short note, more expert people can give you
> better answers. There aren't abstract classes in Python. They are all
> concrete.
Really ? This is like saying there is no singleton in Python...
class AbstractClass(object) :
def __init__(self) : raise RuntimeError('Ths class is an abstract one !')
The abstract class can then define APIs (methods which raise
NotImplementedError) and/or logic (fully implemented methods).
With this scheme you are not stuck to the "API only" usage of abstract classes
like in Java nad its interfaces.
> You may have classes with undefined methods (they may raise
> NotImplementedError).
C++ "pure virtual methods" is only the C++ way of doing something which is a
more general concept in OOP.
--
_____________
Maric Michaud
_____________
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
More information about the Python-list
mailing list