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


Groups > comp.lang.python > #12371

Re: [Python] Why I need the parameter when the call doesn't use it?

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 <chris@gonnerman.org>
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 <chris@gonnerman.org>
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" <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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.526.1314582221.27778.python-list@python.org> (permalink)
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

Show key headers only | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Why I need the parameter when the call doesn't use it? Niklas Rosencrantz <niklasro@gmail.com> - 2011-08-28 17:26 -0700
  Re: Why I need the parameter when the call doesn't use it? Ben Finney <ben+python@benfinney.id.au> - 2011-08-29 11:32 +1000
  Re: [Python] Why I need the parameter when the call doesn't use it? Chris Gonnerman <chris@gonnerman.org> - 2011-08-28 20:42 -0500
    Re: [Python] Why I need the parameter when the call doesn't use it? Ben Finney <ben+python@benfinney.id.au> - 2011-08-29 12:34 +1000
      Re: [Python] Why I need the parameter when the call doesn't use it? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-29 14:40 +1000
  Re: Why I need the parameter when the call doesn't use it? Chris Rebert <clp2@rebertia.com> - 2011-08-28 18:52 -0700
  Re: Why I need the parameter when the call doesn't use it? John Gordon <gordon@panix.com> - 2011-08-29 03:27 +0000
    Re: Why I need the parameter when the call doesn't use it? Ben Finney <ben+python@benfinney.id.au> - 2011-08-29 16:15 +1000

csiph-web