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.


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to