Functions associated with a class.

Kurda Yon kurdayon at yahoo.com
Tue Jul 1 01:44:07 CEST 2008


Hi,

I start to learn the object oriented programing in Python. As far as I
understood, every class has a set of corresponding methods and
variables. For me it is easy to understand a method as a one-argument
function associated with a class. For example, if I call "x.calc" and
"y.calc" and if "x" and "y" belongs to different classes I, actually,
call to different function (the first one is associated with the first
class and the second one with the second class). If "x" and "y"
belongs to the same class, the "x.calc" and "y.calc" refer to the same
function (but called with different arguments ("x" and "y",
respectively)).

In the above described case we have one-argument function. But what
should we do if we one two have a two-argument function. For example,
we want to have a method "calc" which take two objects and returns one
value. How do we call this method? Like "x&y.calc"? Or just calc(x,y)?
In the case of the one-argument functions Pythons automatically decide
which function to call (associated with the first class or with the
second class). Will it be the same in the case of the two-argument
function.

I am not sure that I am clear. If I am not clear, just ask me. I will
try to reformulate my questions.

Thank you.



More information about the Python-list mailing list