Newsgroups: comp.lang.python
From: "Rhodri James" <rho...@wildebst.demon.co.uk>
Date: Fri, 17 Jul 2009 02:31:43 +0100
Local: Thurs, Jul 16 2009 9:31 pm
Subject: Re: Override a method but inherit the docstring
On Fri, 17 Jul 2009 02:01:49 +0100, Ben Finney
<ben+pyt...@benfinney.id.au> wrote: Not really. Consider the case of BarGonk being a subclass of FooGonk > Howdy all, > The following is a common idiom:: > class FooGonk(object): > class BarGonk(FooGonk): > The docstring for ‘FooGonk.frobnicate’ is, intentionally, perfectly > Ideally there would be a way to specify that the docstring should be > class BarGonk(FooGonk): > but that violates DRY (the association between BarGonk and FooGonk is and BazGonk; which docstring would you wish to inherit? > puts the docstring assignment awkwardly after the end Sounds like a job for a decorator! > of the method instead of at the beginning where docstrings normally go, > and reads poorly besides. (This is probably unbelievably ugly and unwise, since I don't use def copydoc(cls): class BarGonk(FooGonk): -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||