Pyenos <[EMAIL PROTECTED]> wrote in 
news:[EMAIL PROTECTED]:

> thanks for your point. so because i have said class blah: i must
> explicitly say self for every instantiation of object?
> 

No, for every method within the class.

Given:

class Blah(object):
        def method1(self,arg1):
                self.x = arg1


b = Blah()      # b is an instance of class Blah

b.method1(32)           # when you invoke it, just pass arg1

print b.x       # prints 32

                        

The use of 'self' is just a convention, but a *very* common one, 
and one you should follow if you expect other Python programmers 
to read your code. This is legal, and has the same effect as the 
above class:

class Blah2(object):
        def method1(spugsl,arg1):
                spugsl.x = arg1

Spugsl (or self) is just the way to refer to the instance within 
the code.

In your code, each method wound up with a different name, and none 
of the names would have been associated with what you would have 
expected. So for example, in 

def removeEntry(pid_to_remove, task_to_remove):

... your equivalent to 'self' would be pid_to_remove, and the pid 
you passed in would have been associated with task_to_remove.

-- 
rzed



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

Reply via email to