self is the class instance that the bound function being called belongs
to. This example should illustrate a bit.


class Foo(object):
    def __init__(self, value):
        self.value = value # so the Foo instance now has an attribute,
value

    def get_value(self):
        return self.value # This gets the previously-set value
attribute of the Foo instance

bar = Foo(42)
baz = Foo('101010')

print bar.get_value() #Note that the self argument is implicit since
this is a bound method.
print
print baz.get_value()

The output is (or should be, as this is untested):
42

101010

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

Reply via email to