Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7424

Re: __doc__ immutable for classes

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'function,': 0.07; 'read- only': 0.07; 'terry': 0.07; 'wrapper': 0.07; '*is*': 0.09; '3.x': 0.09; 'attribute': 0.09; 'presume': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'underlying': 0.09; 'wrappers': 0.09; 'writable': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'function?': 0.16; 'reedy': 0.16; 'subject:classes': 0.16; 'method.': 0.16; "wouldn't": 0.17; 'jan': 0.20; 'header:In-Reply-To:1': 0.21; 'gregory': 0.23; 'objects': 0.23; 'function': 0.25; 'string': 0.26; 'work.': 0.28; 'bound': 0.29; 'instead': 0.29; 'binding': 0.30; 'blocks': 0.30; 'ewing': 0.30; 'header:X-Complaints-To:1': 0.32; 'does': 0.33; 'to:addr:python-list': 0.33; 'first.': 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; 'doc': 0.35; 'hold': 0.36; 'probably': 0.36; 'change': 0.37; 'received:org': 0.38; 'but': 0.38; 'eric': 0.38; 'subject:: ': 0.38; 'should': 0.39; 'header:Mime-Version:1': 0.39; 'got': 0.39; 'to:addr:python.org': 0.39; 'custom': 0.60; 'surprises.': 0.84; 'snow': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: __doc__ immutable for classes
Date Fri, 10 Jun 2011 21:17:09 -0400
References <mailman.65.1307662177.11593.python-list@python.org> <95dvi9Fq9nU1@mid.individual.net>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host rain.gmane.org
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10
In-Reply-To <95dvi9Fq9nU1@mid.individual.net>
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.119.1307755044.11593.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 82.94.164.166
X-Trace 1307755044 news.xs4all.nl 49044 [::ffff:82.94.164.166]:36021
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7424

Show key headers only | View raw


On 6/10/2011 3:31 AM, Gregory Ewing wrote:
> Eric Snow wrote:
>> But for "method" objects (really a wrapper for
>> bound functions) would it change the __doc__ of the wrapper or of the
>> bound function?
>
> You probably wouldn't want to change the __doc__ of a method
> wrapper; instead you'd make sure you got hold of the underlying
> function first. So __doc__ on method wrappers should probably
> remain read-only to avoid surprises.

In 3.x there are no general method wrappers; only bound methods. The 
.__doc__ attribute of bound methods equals and I am very sure *is* the 
doc string of the underlying function, accessed through a custom 
method.__getattr__. It is not writable through the bound method. I 
presume this is because method.__setattr__ blocks the write. Directly 
binding a new string to the underlying function does work.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

__doc__ immutable for classes (was: Re: how to inherit docstrings?) Eric Snow <ericsnowcurrently@gmail.com> - 2011-06-09 17:29 -0600
  Re: __doc__ immutable for classes (was: Re: how to inherit docstrings?) Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-06-10 19:31 +1200
    Re: __doc__ immutable for classes Terry Reedy <tjreedy@udel.edu> - 2011-06-10 21:17 -0400

csiph-web