I’ve noticed a discrepancy in the way that python parameters are called. In every other language I’ve dealt with, you either have
foo()
meaning either no parameters, or as many parameters as you like, or
foo(arg1, arg2,...,argn)
where you pass in the same number of parameters to define the function and call it. In python however, I’ve noticed that the function definitions, and when the function is called, can have two different parameters sets, this usually consists of:
class foo(object):
def bar(self, arg1, arg2):
pass
However, when I want to call the function, all I have to do is:
zoo = foo()
zoo.bar(arg1, arg2)
Where did the self parameter go?
Thank you.
It’s in front of the dot when you call the function, i.e. in your case it’s
zoo.Note that you can also call the function as
foo.bar(zoo, arg1, arg2). Basically in pythonobject.method(arguments)is a shortcut forobjects_class.method(object, arguments).