Abstract Methods & Abstract Class
Fredrik Lundh
fredrik at pythonware.com
Thu Oct 20 03:16:27 EDT 2005
Andreas Kostyrka wrote:
> > Do we have something like abstract methods & Abstract class.
> >
> > So that my class would just define the method. And the implementation
> > would be defined by somebody else.
>
> class AbstractBase:
> def method(self):
> raise TypeError("abstract method called")
>
> But basically, Python does not have abstract methods, and usually doesn't
> need them.
the NotImplementedError exception is usually a better choice:
class AbstractBase:
def method(self):
raise NotImplementedError("'method' implementation missing")
</F>
More information about the Python-list
mailing list