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


Groups > comp.lang.python > #30126

Re: data attributes override method attributes?

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 <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; '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 <tjreedy@udel.edu>
Subject Re: data attributes override method attributes?
Date Tue, 25 Sep 2012 16:34:12 -0400
References <931902e1-570b-4288-bb9b-de711318c5cd@googlegroups.com> <mailman.1338.1348582105.27098.python-list@python.org> <c3fb0a89-abb9-4107-89cd-3f4ee17b40e1@t2g2000pbt.googlegroups.com> <k3sgio$9v$1@ger.gmane.org> <CAPTjJmo9A2_0hjy2RJW+ALAvd4CTmUfOfh8sy7LspSJxdiWPgw@mail.gmail.com> <k3t2di$9f6$1@ger.gmane.org> <CALwzidk+8BftxXffxidEBZn9xwq6bDMAcTa81HYpq8jGfE=BqA@mail.gmail.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 <CALwzidk+8BftxXffxidEBZn9xwq6bDMAcTa81HYpq8jGfE=BqA@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.1376.1348605281.27098.python-list@python.org> (permalink)
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

Show key headers only | View raw


On 9/25/2012 4:07 PM, Ian Kelly wrote:
> On Tue, Sep 25, 2012 at 1:58 PM, Terry Reedy <tjreedy@udel.edu> 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

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


Thread

data attributes override method attributes? Jayden <jayden.shui@gmail.com> - 2012-09-25 06:41 -0700
  Re: data attributes override method attributes? alex23 <wuwei23@gmail.com> - 2012-09-25 06:52 -0700
  Re: data attributes override method attributes? Peter Otten <__peter__@web.de> - 2012-09-25 16:08 +0200
    Re: data attributes override method attributes? alex23 <wuwei23@gmail.com> - 2012-09-25 07:11 -0700
      Re: data attributes override method attributes? Peter Otten <__peter__@web.de> - 2012-09-25 16:54 +0200
      Re: data attributes override method attributes? Chris Angelico <rosuav@gmail.com> - 2012-09-26 01:03 +1000
      Re: data attributes override method attributes? Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-09-25 16:54 +0200
      Re: data attributes override method attributes? Terry Reedy <tjreedy@udel.edu> - 2012-09-25 15:58 -0400
      Re: data attributes override method attributes? Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-25 14:07 -0600
      Re: data attributes override method attributes? Terry Reedy <tjreedy@udel.edu> - 2012-09-25 16:18 -0400
      Re: data attributes override method attributes? Terry Reedy <tjreedy@udel.edu> - 2012-09-25 16:34 -0400
      RE: data attributes override method attributes? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-09-28 18:02 +0000
        Re: data attributes override method attributes? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-29 03:20 +0000
      Re: data attributes override method attributes? Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-28 12:25 -0600
      Re: data attributes override method attributes? Terry Reedy <tjreedy@udel.edu> - 2012-09-28 14:26 -0400
    Re: data attributes override method attributes? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-09-25 21:52 +0200
  Re: data attributes override method attributes? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-25 14:12 +0000

csiph-web