Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'wed,': 0.03; 'instance': 0.05; 'worse': 0.07; 'append': 0.09; 'line:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'tuple': 0.09; 'def': 0.12; '(name,': 0.16; 'bieber': 0.16; 'declaimed': 0.16; 'element,': 0.16; 'email addr:ix.netcom.com': 0.16; 'email name:wlfraed': 0.16; 'from:addr:ix.netcom.com': 0.16; 'from:addr:wlfraed': 0.16; 'from:name:dennis lee bieber': 0.16; 'hudson': 0.16; 'received:66.245': 0.16; 'received:dsl.mindspring.com': 0.16; 'received:mindspring.com': 0.16; 'received:wlfraed': 0.16; 'replaces': 0.16; 'subject:Objects': 0.16; 'subject:PLEASE': 0.16; 'url:netcom': 0.16; 'url:wlfraed': 0.16; 'wulfraed': 0.16; 'method.': 0.16; 'url:home': 0.25; 'lee': 0.29; 'subject:HELP': 0.29; 'class': 0.29; "won't": 0.30; 'binding': 0.30; 'that...': 0.30; 'header:X -Complaints-To:1': 0.32; 'to:addr:python-list': 0.33; 'list': 0.33; '-0700,': 0.35; 'charset:us-ascii': 0.36; 'created': 0.36; 'received:org': 0.38; 'subject:: ': 0.38; 'called': 0.39; 'header :Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'subject:, ': 0.60; 'your': 0.60; 'dennis': 0.77; '(single': 0.84; 'subject:Methods': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Of Functions, Objects, and Methods-I NEED HELP PLEASE Date: Thu, 09 Jun 2011 10:25:36 -0700 Organization: > Bestiaria Support Staff < References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: user-11fb5d1.dsl.mindspring.com X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 82.94.164.166 X-Trace: 1307640355 news.xs4all.nl 49178 [::ffff:82.94.164.166]:48324 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7309 On Wed, 08 Jun 2011 23:59:35 -0700, Larry Hudson declaimed the following in gmane.comp.python.general: > > class Dog(): > > def __init__(self, name, breed): > > self.name = name > > self.breed = breed > > > > def dogAppend(self): > > self.dogAppend = [] > > self.dogAppend.append((self.name,self.breed)) > > return self.dogAppend > > 2: This won't work to append to your list anyway... each time you call dogAppend() it will > clear out any existing list and result in a list of one element, a tuple of (name, breed). You > can do exactly the same thing with a single line: return [(self.name, self.breed)] > Worse than that... The first time dogAppend is called on an instance of Dog, it replaces the dogAppend method with a binding to the (single element) list created by the method. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/