Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7278
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ericsnowcurrently@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'pursuing': 0.05; '"""': 0.07; '2004': 0.09; 'attribute': 0.09; 'attribute.': 0.09; 'elegant,': 0.09; 'module)': 0.09; "object's": 0.09; 'writable': 0.09; '>>>': 0.12; 'examples': 0.12; 'am,': 0.14; 'wrote:': 0.14; '(whether': 0.16; '3.3.': 0.16; 'clear:': 0.16; 'decorators.': 0.16; 'docstring': 0.16; 'docstrings': 0.16; 'finney': 0.16; 'inheriting': 0.16; 'metaclasses': 0.16; 'repetition,': 0.16; '\xa0def': 0.16; 'case.': 0.16; 'traceback': 0.16; '(most': 0.16; 'cc:addr:python-list': 0.17; 'solution.': 0.19; 'writes:': 0.19; 'header:In-Reply-To:1': 0.21; 'thu,': 0.22; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'all:': 0.23; 'last):': 0.23; 'objects': 0.23; 'function': 0.25; 'url:mailman': 0.26; 'object': 0.26; "i'm": 0.27; 'message-id:@mail.gmail.com': 0.28; 'thanks': 0.28; 'subject:how': 0.29; 'subject:?': 0.29; 'sorry,': 0.29; 'class': 0.29; 'cc:addr:python.org': 0.30; 'url:listinfo': 0.30; 'decorators': 0.30; 'received:209.85.215': 0.30; 'too': 0.33; 'rather': 0.34; 'file': 0.34; 'thinking': 0.34; 'however,': 0.34; '"",': 0.35; 'using': 0.35; 'idea': 0.36; '8bit%:8': 0.36; 'too.': 0.37; 'received:google.com': 0.37; 'something': 0.37; 'change': 0.37; 'received:209.85': 0.37; 'involving': 0.37; 'url:python': 0.38; 'url:org': 0.38; 'but': 0.38; 'eric': 0.38; 'subject:: ': 0.38; 'should': 0.39; 'received:209': 0.39; 'missing': 0.40; 'really': 0.40; 'science': 0.40; 'more': 0.60; 'body': 0.61; 'free': 0.63; 'link': 0.64; 'believe': 0.66; 'p.s.': 0.67; 'god': 0.76; '"some': 0.84; 'adopt': 0.84; 'beliefs': 0.84; 'difficult.': 0.91; 'harris,': 0.91; 'snow': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=WCWAeO7NJ3Z2qLDz3E5/U7UpK+eogvTkut777sYOUNM=; b=u9f3Sgagz0wZGaoEXM0Gehd6x0ud/BP0ixuXkAjpL9i1ISEWqoTSoWOf2Adgfcg8p4 xqWZdR4mmsWdxRE4rLjW4HGUl8Wn5nUc/1D1HbXW68YpISu0agQlvj9thNKAbxZEFA7a ex1Ts1fdPUXAbyvaX+jBNmHKpZG9it8Z4qlAQ= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=ZTFy9xk8CQOoHtIqw9djIbWssGmJ6VRGeCjZuLJ+7r5PJkaAMKhclmf42a5tslFyU+ Yuvl0uhzkH8bYYaJ+a4x03veA2sUHvLfZ1hA3R12RhwNlF+ppjazPb+GYDvauFiBdEoP 83u0QeYyFngdmNUIEmfO0pznf1YU1lxSSDKCU= |
| MIME-Version | 1.0 |
| In-Reply-To | <87k4cvy0gc.fsf@benfinney.id.au> |
| References | <mailman.42.1307600576.11593.python-list@python.org> <87k4cvy0gc.fsf@benfinney.id.au> |
| Date | Thu, 9 Jun 2011 01:13:06 -0600 |
| Subject | Re: how to inherit docstrings? |
| From | Eric Snow <ericsnowcurrently@gmail.com> |
| To | Ben Finney <ben+python@benfinney.id.au> |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.44.1307603589.11593.python-list@python.org> (permalink) |
| Lines | 66 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1307603589 news.xs4all.nl 49039 [::ffff:82.94.164.166]:58219 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:7278 |
Show key headers only | View raw
On Thu, Jun 9, 2011 at 12:37 AM, Ben Finney <ben+python@benfinney.id.au> wrote: > Eric Snow <ericsnowcurrently@gmail.com> writes: > >> p.s. Am I missing something or can you really not change the docstring >> of a class? I was thinking about the idea of inheriting class >> docstrings too. > > The docstring of an object (whether function or class or module) is the > object's ‘__doc__’ attribute. Access that attribute to get the > docstring; re-bind that attribute to set a different docstring. > Sorry, I should have been more clear: >>> class X: ... "some doc" ... >>> X.__doc__ 'some doc' >>> X.__doc__ = "another doc" Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: attribute '__doc__' of 'type' objects is not writable That is on 3.3. > So, it's even possible to do what you ask without decorators at all: > > class Foo(object): > def frob(self): > """ Frobnicate thyself. """ > > class Bar(Foo): > def frob(self): > pass > frob.__doc__ = Foo.frob.__doc__ > > Not very elegant, and involving rather too much repetition; but not > difficult. > Yeah, definitely you can do it directly for each case. However, the inelegance, repetition, and immodularity are exactly why I am pursuing a solution. :) (I included a link in the original message to examples of how you can already do it with metaclasses and class decorators too.) I'm just looking for a way to do it with decorators in the class body without using metaclasses or class decorators. Thanks -eric > -- > \ “We are no more free to believe whatever we want about God than | > `\ we are free to adopt unjustified beliefs about science or | > _o__) history […].” —Sam Harris, _The End of Faith_, 2004 | > Ben Finney > -- > http://mail.python.org/mailman/listinfo/python-list >
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to inherit docstrings? Eric Snow <ericsnowcurrently@gmail.com> - 2011-06-09 00:22 -0600
Re: how to inherit docstrings? Ben Finney <ben+python@benfinney.id.au> - 2011-06-09 16:37 +1000
Re: how to inherit docstrings? Eric Snow <ericsnowcurrently@gmail.com> - 2011-06-09 01:13 -0600
Re: how to inherit docstrings? Ben Finney <ben+python@benfinney.id.au> - 2011-06-09 17:44 +1000
Re: how to inherit docstrings? Duncan Booth <duncan.booth@invalid.invalid> - 2011-06-09 11:23 +0000
Re: how to inherit docstrings? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-09 14:56 +0000
Re: how to inherit docstrings? Ben Finney <ben+python@benfinney.id.au> - 2011-06-10 07:33 +1000
Re: how to inherit docstrings? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-10 09:25 +0000
Re: how to inherit docstrings? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-10 16:47 +0000
Re: how to inherit docstrings? Eric Snow <ericsnowcurrently@gmail.com> - 2011-06-10 11:01 -0600
Re: how to inherit docstrings? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-10 17:27 +0000
Re: how to inherit docstrings? Eric Snow <ericsnowcurrently@gmail.com> - 2011-06-10 12:48 -0600
Re: how to inherit docstrings? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-10 17:19 +0000
csiph-web