Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'instance': 0.05; 'parameter': 0.05; 'subject:Python': 0.06; 'function,': 0.07; 'subject:when': 0.07; 'python': 0.08; 'argument,': 0.09; 'subject:] ': 0.14; 'def': 0.15; 'argument': 0.15; 'method.': 0.15; 'subject:use': 0.15; 'hacked': 0.16; 'object)': 0.16; 'parameter,': 0.16; 'received:67.18.44': 0.16; 'webapp': 0.16; 'wrote:': 0.16; '(i.e.': 0.17; 'header:In-Reply- To:1': 0.22; 'to:name:python-list@python.org': 0.23; 'pm,': 0.24; 'object,': 0.24; 'code': 0.25; "i'm": 0.27; 'function': 0.27; 'subject:need': 0.28; 'from:addr:chris': 0.30; 'class': 0.30; 'subject:?': 0.31; '----': 0.32; "isn't": 0.33; 'to:addr:python- list': 0.33; 'it?': 0.33; 'calling': 0.33; "i've": 0.34; 'header :User-Agent:1': 0.34; 'skip:b 40': 0.34; 'test': 0.34; 'reference': 0.35; 'some': 0.38; 'else': 0.39; 'define': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; "it's": 0.40; 'where': 0.40; 'your': 0.61; 'received:websitewelcome.com': 0.64; 'received:184': 0.67; '07:26': 0.84; 'subject:call': 0.91 Date: Sun, 28 Aug 2011 20:42:32 -0500 From: Chris Gonnerman User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.20) Gecko/20110805 Thunderbird/3.1.12 MIME-Version: 1.0 To: "python-list@python.org" Subject: Re: [Python] Why I need the parameter when the call doesn't use it? References: <66a3f64c-d35e-40c7-be69-ddf708e37ba7@glegroupsg2000goo.googlegroups.com> In-Reply-To: <66a3f64c-d35e-40c7-be69-ddf708e37ba7@glegroupsg2000goo.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator191.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - gonnerman.org X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([10.0.1.176]) [207.192.237.37]:56690 X-Source-Auth: chris@newcenturycomputers.net X-Email-Count: 2 X-Source-Cap: bmV3Y2VudDtuZXdjZW50O2dhdG9yMTkxLmhvc3RnYXRvci5jb20= 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1314582221 news.xs4all.nl 2441 [2001:888:2000:d::a6]:46570 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12371 On 08/28/2011 07:26 PM, Niklas Rosencrantz wrote: > I modularize code for a webapp and I want to know what python makes that a need to define an argument called self? Here's some code where I'm modularizing a recaptcha test to a function and the I must add the parameter "self" to the function is_submitter_human: > > ---- > class A(BaseHandler, blobstore_handlers.BlobstoreUploadHandler): > def is_submitter_human(self): is_submitter_human() isn't a function, it's a method. Methods are always called with a reference to the class instance (i.e. the object) that the method belongs to; this reference is the first argument, and is conventionally called "self". Though I've hacked it out, your code sample includes calls to other methods of the object, by calling self.methodname(). Without the first parameter, how else would you do it? -- Chris.