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: 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 Subject: Re: __doc__ immutable for classes Date: Fri, 10 Jun 2011 21:17:09 -0400 References: <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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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