Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '"""': 0.05; 'attribute': 0.05; 'attributes': 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; 'applies': 0.15; 'accidental': 0.16; 'attributes.': 0.16; 'between.': 0.16; 'namespace.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'url:py3k': 0.16; 'string': 0.17; 'wrote:': 0.17; 'instance': 0.17; 'replacing': 0.17; 'url:dev': 0.17; 'jan': 0.18; '>>>': 0.18; 'name;': 0.22; 'url:bugs': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'am,': 0.27; 'bugs': 0.27; 'convention': 0.27; 'header:X-Complaints-To:1': 0.28; '(perhaps': 0.29; '>>>>': 0.29; 'methods.': 0.29; 'class': 0.29; 'usually': 0.30; 'url:python': 0.32; 'conventions': 0.33; 'subject:data': 0.33; 'to:addr:python- list': 0.33; 'tutorial': 0.33; 'agree': 0.34; 'wrong': 0.34; 'subject:?': 0.35; 'something': 0.35; 'received:org': 0.36; 'except': 0.36; 'url:org': 0.36; 'method': 0.36; 'should': 0.36; 'possible': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'url:docs': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'share': 0.61; 'chance': 0.61; 'kind': 0.61; 'within': 0.64; '26,': 0.65; 'programs,': 0.71; 'special': 0.73; 'capitalizing': 0.84; 'otten': 0.84; 'received:fios.verizon.net': 0.84; 'conflicts,': 0.91; 'url:tutorial': 0.93 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:18:26 -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: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348604334 news.xs4all.nl 6906 [2001:888:2000:d::a6]:46184 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30125 On 9/25/2012 10:54 AM, Peter Otten wrote: > alex23 wrote: > >> On Sep 26, 12:08 am, Peter Otten <__pete...@web.de> wrote: >>> Jayden wrote: >>>> In the Python Tutorial, Section 9.4, it is said that >>> >>>> "Data attributes override method attributes with the same name." >>> >>> The tutorial is wrong here. That should be >>> >>> "Instance attributes override class attributes with the same name." Except for special methods. > I would even consider replacing the whole paragraph I agree > > """ > Data attributes override method attributes with the same name; to avoid > accidental name conflicts, which may cause hard-to-find bugs in large > programs, it is wise to use some kind of convention that minimizes the > chance of conflicts. Possible conventions include capitalizing method names, > prefixing data attribute names with a small unique string (perhaps just an > underscore), or using verbs for methods and nouns for data attributes. > """ > http://docs.python.org/dev/py3k/tutorial/classes.html > > with something like > > "Data attributes and method attributes share the same namespace. and instance attributes usually override class attributes > To avoid > name conflicts consider using verbs for methods and nouns for data > attributes" This applies within and between. I opened http://bugs.python.org/issue16048 -- Terry Jan Reedy