Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'created,': 0.09; 'subject:parameters': 0.09; 'stored': 0.13; 'wrote:': 0.15; 'does,': 0.16; 'len': 0.16; 'received:192.168.1.40': 0.16; 'typo': 0.16; 'argument': 0.16; 'looked': 0.16; 'def': 0.16; 'header:In- Reply-To:1': 0.22; 'function': 0.26; '(in': 0.26; 'work:': 0.29; "won't": 0.32; 'does': 0.32; 'to:addr:python-list': 0.34; 'header :User-Agent:1': 0.34; 'that,': 0.35; 'function.': 0.35; 'skip:" 10': 0.36; 'received:192': 0.38; 'subject:: ': 0.38; 'think': 0.38; 'received:192.168.1': 0.39; 'to:addr:python.org': 0.39; 'did': 0.40; 'received:62': 0.67; 'from:addr:t': 0.84 Date: Fri, 22 Jul 2011 14:06:07 +0200 From: Thomas Jollans User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110626 Iceowl/1.0b2 Icedove/3.1.11 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Use self.vars in class.method(parameters, self.vars) References: <0ddc2626-7b99-46ee-9974-87439ae09f1e@e40g2000yqn.googlegroups.com> <4E295FBF.3040402@free.fr> In-Reply-To: <4E295FBF.3040402@free.fr> X-Enigmail-Version: 1.1.2 OpenPGP: id=5C8691ED Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1311336366 news.xs4all.nl 23909 [2001:888:2000:d::a6]:40116 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10101 On 22/07/11 13:32, Karim wrote: > > I think you did a typo > > it is > > def foo2(self, len = self._myvar): > while i< len: > dosomething > That, of course, won't work: the default argument (in this case: "self._myvar") is looked up when the function is created, and stored with the function. "self" does not exist at that point. (or, if it does, it's the wrong "self")