Use empty string for self
johnjsal at NOSPAMgmail.com
Wed Mar 1 15:54:35 CET 2006
James Stroud wrote:
> py> def doittoit(it):
> ... print it.whatzit
> py> class It:
> ... whatzit = 42
> ... def doittoit(self):
> ... print self.whatzit
> py> anit = It()
> py> doittoit(anit)
> py> It.doittoit(anit)
> py> anit.doittoit()
> If you get this example, I'm pretty sure you will understand "self" and
> its necessity.
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. I'm trying to train myself to see
def doittoit(self) as def doittoit()
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.
More information about the Python-list