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


Groups > comp.lang.python > #30420

RE: data attributes override method attributes?

Path csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ramit.prasad@jpmorgan.com>
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; 'completeness': 0.07; 'method,': 0.07; 'override': 0.07; 'python': 0.09; 'received:155': 0.09; 'sep': 0.09; 'subject:method': 0.09; 'terry': 0.09; 'accesses': 0.16; 'attributes.': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'received:155.180': 0.16; 'received:159.53': 0.16; 'received:169.70': 0.16; 'received:169.70.184': 0.16; 'received:169.70.184.72': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:hubcr105.exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'reedy': 0.16; 'securities,': 0.16; 'skipped': 0.16; 'skips': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'instance,': 0.17; '>>>': 0.18; 'code.': 0.20; 'issue.': 0.20; 'otherwise,': 0.20; 'to:name:python- list@python.org': 0.20; 'class.': 0.23; 'received:169.254': 0.24; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'accuracy': 0.27; 'chris': 0.28; 'received:169': 0.29; 'class': 0.29; 'filled': 0.30; 'function': 0.30; 'header:Received:8': 0.30; 'code': 0.31; 'goes': 0.33; 'instances': 0.33; 'subject:data': 0.33; 'to:addr :python-list': 0.33; 'so,': 0.35; 'pm,': 0.35; 'too.': 0.35; 'subject:?': 0.35; 'something': 0.35; 'except': 0.36; 'method': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'things': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'think': 0.40; 'information,': 0.63; 'url:email': 0.63; 'legal': 0.65; 'subject': 0.66; 'purchase': 0.67; 'direct': 0.69; 'special': 0.73; 'sale': 0.76; 'received:169.254.8': 0.84; 'reminds': 0.84; 'why?': 0.84; 'hand,': 0.97
X-DKIM OpenDKIM Filter v2.1.3 sf3.jpmchase.com q8SI29LH014901
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1348855329; bh=ERUgJWglVYoCSAiswk6Inhi33rizvjVPJmU6NtpfSws=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=TwUWWOgRsQA77wZUI+RANuAj6Ma2SY0EjkY20okA7fqNS/CUYSyXRH76rLOQ9RiWz SxEvFENrcILhIm7X8QJfv043daEZ7juRRvTOBxazCwrhU5lDmseYRLU8PlSsD2ROv4 iUjO2zp/X4ZGuR/30kWdsTXzHoa29XBEN/DO1KL4=
From "Prasad, Ramit" <ramit.prasad@jpmorgan.com>
To "python-list@python.org" <python-list@python.org>
Subject RE: data attributes override method attributes?
Thread-Topic data attributes override method attributes?
Thread-Index AQHNmy2fx+iO8l32NkO+geClnPNL35ebanYAgABSfACAAAKqAIAAB1UAgARIStA=
Date Fri, 28 Sep 2012 18:02:04 +0000
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> <k3t4gj$ral$1@ger.gmane.org>
In-Reply-To <k3t4gj$ral$1@ger.gmane.org>
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.67.79.47]
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-DLP-FWD Yes
Content-Type text/plain; charset="us-ascii"
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.1575.1348855339.27098.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348855339 news.xs4all.nl 6914 [2001:888:2000:d::a6]:56028
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30420

Show key headers only | View raw


Terry Reedy wrote:
> 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.
> 


Just to make sure I am following, if you call
foo.__len__() it goes to the instance code while
if you do len(foo) it will go to class.__len__()?

If so, why? 

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

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