Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'attributes': 0.07; 'method,': 0.07; 'override': 0.07; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sep': 0.09; 'subject:method': 0.09; 'terry': 0.09; 'accesses': 0.16; 'attributes.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'skipped': 0.16; 'skips': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'instance,': 0.17; 'jan': 0.18; '>>>': 0.18; 'code.': 0.20; 'issue.': 0.20; 'otherwise,': 0.20; 'class.': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'header:X-Complaints- To:1': 0.28; 'chris': 0.28; 'class': 0.29; 'filled': 0.30; 'function': 0.30; 'goes': 0.33; 'instances': 0.33; 'subject:data': 0.33; 'to:addr:python-list': 0.33; 'pm,': 0.35; 'too.': 0.35; 'subject:?': 0.35; 'something': 0.35; 'received:org': 0.36; 'except': 0.36; 'method': 0.36; 'should': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'direct': 0.69; 'special': 0.73; 'received:fios.verizon.net': 0.84; 'reminds': 0.84; 'hand,': 0.97 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: data attributes override method attributes? Date: Tue, 25 Sep 2012 16:34:12 -0400 References: <931902e1-570b-4288-bb9b-de711318c5cd@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120824 Thunderbird/15.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348605281 news.xs4all.nl 6978 [2001:888:2000:d::a6]:54694 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30126 On 9/25/2012 4:07 PM, Ian Kelly wrote: > On Tue, Sep 25, 2012 at 1:58 PM, Terry Reedy wrote: >> On 9/25/2012 11:03 AM, Chris Angelico wrote: >>> Instance attributes override (shadow) class attributes. >> >> >> except for (some? all?) special methods > > Those names are shadowed too. If you call foo.__len__() and the name > is bound on the instance, it will call that function preferentially. > It's just that when the special Python machinery calls the method, it > skips the instance and goes straight to the class. I added "Ian Kelly reminds me that instance.__xxx__ is only skipped by the internal machinery and not by direct accesses in user code. In the other hand, docs, official or otherwise, are filled with things like 'len(a) calls a.__len__', so I think something should be said that giving instances special method attributes does not have the effect one might expect." to the issue. -- Terry Jan Reedy