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

Ben Finney ben+python at benfinney.id.au
Mon Aug 29 04:34:23 CEST 2011

Chris Gonnerman <chris at 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

More information about the Python-list mailing list