how to inherit docstrings?

Gregory Ewing greg.ewing at canterbury.ac.nz
Fri Jun 10 03:16:15 EDT 2011


Carl Banks wrote:

> Presumably, the reason you are overriding a method in a subclass
> is to change its behavior;

Not always true by any means, and maybe not even usually true.
Consider overriding for the purpose of implementing an abstract
method, or because something about the internal operation of a
method needs to be modified to suit the requirements of the subclass.

I have a lot of situations like this in PyGUI, where there is a
bunch of generic classes defining the public API, and subclasses
of them for each implementation (Cocoa, Gtk and Windows). There
are heaps and heaps of overridden methods in the implementation
classes, and very few of them need or should have a docstring
different from the generic one. Not automatically inheriting
the docstrings puts a big burden on the maintainer to keep all
of them in sync.

-- 
Greg



More information about the Python-list mailing list