Quote:
|
Originally Posted by bulio
Is it because self will make the object run what is inside of it? (And therefore use the print?)
|
I'm not quite sure what you mean here.
In Python, the first argument of a method belonging to a function is a reference to the object the function is contained within. This argument is, by convention, called "self".
Thus:
Is the same as:
x = MyClass()
MyClass.foobar(x)
The "self" argument allows a method to access the object in which it is contained.
e.g.:
class Test:
def __init__(self):
self.x = 10
self.y = 5
t = Test()
print t.x, t.y Prints out: