Abstract classes?
Gerrit Holl
gerrit.holl at pobox.com
Thu Feb 17 10:10:58 EST 2000
Skip Montanaro wrote on 950771718:
>
> Daniel> class Observer:
> Daniel> def update( self ):
> Daniel> raise "sub-classes must over-ride this method"
>
> You might want to raise the standard NotImplementedError. From its doc
> string:
>
> >>> help(NotImplementedError)
> Method or function hasn't been implemented yet.
Daniel, please note that you probably don't have the help() function.
It's a function written by Skip to print an objects __doc__ attribute. So
this is really equivalent to:
print NotImplementedError.__doc__
You could write the help function like this:
def help(obj):
"""help(obj) -> None
Print the docstring of an object to sys.stdout.
"""
if hasattr(obj, "__doc__):
print obj.__doc__
else:
print obj, "doesn't have a docstring"
regards,
Gerrit.
--
cat: /home/gerrit/.signature: No such file or directory
More information about the Python-list
mailing list