Use empty string for self

Grant Edwards grante at
Wed Mar 1 17:14:32 CET 2006

On 2006-03-01, John Salerno <johnjsal at> wrote:

> I do get it. I think I will just have to get used to seeing
> the 'self' argument but understanding that it's not really
> something that is always passed in.

But it _is_ always passed to the function.  You can even pass
it explicity when you call the method if you want:

  class MyClass:
      def mymethod(self,p1,p2):
          print self,p1,p2
  instance = MyClass()



The two calls are equivalent.  

> I'm trying to train myself to see
> def doittoit(self) as def doittoit()

You would be misleading yourself.

> Of course, that might not be a good strategy, because I know
> when it isn't used as an instance method (is that C
> terminology?), then you must explicitly pass the self
> argument.


Grant Edwards                   grante             Yow!  I guess we can live
                                  at               on his POT FARM in HADES!!

More information about the Python-list mailing list