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


Groups > comp.lang.python > #30096

Re: data attributes override method attributes?

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>
Date 2012-09-26 01:03 +1000
Subject Re: data attributes override method attributes?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1343.1348585397.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Sep 26, 2012 at 12:54 AM, Peter Otten <__peter__@web.de> wrote:
> To me
>
> "Data attributes override method attributes with the same name"
>
> implies that data attributes take precedence over method attributes, not
> that they replace them only when there is an assignment of data after the
> method definition.
>
> I would even consider replacing the whole paragraph
> with something like
>
> "Data attributes and method attributes share the same namespace. To avoid
> name conflicts consider using verbs for methods and nouns for data
> attributes"

Instance attributes override (shadow) class attributes. Since methods
tend to be on the class and data tends to be on the instance, the
original sentence does make some sense. The section is talking about
conventions, so it's not inherently wrong, but perhaps just needs a
comment about methods not usually being attached to the instance.

ChrisA

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