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


Groups > comp.lang.python > #12374

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

From Ben Finney <ben+python@benfinney.id.au>
Newsgroups comp.lang.python
Subject Re: [Python] Why I need the parameter when the call doesn't use it?
References <66a3f64c-d35e-40c7-be69-ddf708e37ba7@glegroupsg2000goo.googlegroups.com> <mailman.526.1314582221.27778.python-list@python.org>
Date 2011-08-29 12:34 +1000
Message-ID <87fwklt07k.fsf@benfinney.id.au> (permalink)
Organization Unlimited download news at news.astraweb.com

Show all headers | View raw


Chris Gonnerman <chris@gonnerman.org> writes:

> On 08/28/2011 07:26 PM, Niklas Rosencrantz wrote:
> > class A(BaseHandler, blobstore_handlers.BlobstoreUploadHandler):
> >      def is_submitter_human(self):

> is_submitter_human() isn't a function, it's a method.

No, that's not true and may lead to future confusion.

Rather, it is a function *and* a method. Not all functions are methods,
but all methods are functions.

> Methods are always called with a reference to the class instance

Also not true, but perhaps too subtle an issue to explore in this thread.

> 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?

Yes, that's exactly the reason. Thanks.

-- 
 \         “A child of five could understand this. Fetch me a child of |
  `\                                              five.” —Groucho Marx |
_o__)                                                                  |
Ben Finney

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