Newsgroups: comp.lang.python
From: Jean-Paul Calderone <exar...@divmod.com>
Date: Thu, 16 Jul 2009 21:13:34 -0400
Local: Thurs, Jul 16 2009 9:13 pm
Subject: Re: Override a method but inherit the docstring
On Fri, 17 Jul 2009 11:01:49 +1000, Ben Finney <ben+pyt...@benfinney.id.au> wrote: How about this? >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 >What is the most Pythonic, DRY-adherent, and preferably least-ugly class BarGonk(FooGonk): The implementation of "inherit_docstring" is left as an exercise for the By the way, I don't think this is a particularly good idea. Presumably class BarGonk(FooGonk): With the result of BarGonk.frobnicate.__doc__ being set to: Frobnicate this gonk. This implementation takes the warble into consideration. Jean-Paul 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.
| ||||||||||||||