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)
> 42
> py> It.doittoit(anit)
> 42
> py> anit.doittoit()
> 42
> 
> 
> 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.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to