Hello Ian, Ian Kelly <ian.g.ke...@gmail.com> writes:
> On Thu, Apr 5, 2012 at 10:50 AM, yag <yagn...@live.com> wrote: >> three classes A,B,C and instance x. >> >> now how can I call methods foo in class A and B using 'x' instance. (I hope I >> could pronounce the terminology correct) > > Do you mean that you want C.foo to call B.foo, and B.foo to call > A.foo? If that is the case, just use super(), as you already do with > the __init__ method. > > Or do you want to skip C.foo and call A.foo or B.foo directly? yes! >In that case, just call it from the specific class you want. Since you > are dispatching from the class instead of the instance, I couldn't understand what you mean here, (may be because my poor knowledge with the terminology) >you will have > to pass the instance in explicitly as the self argument. For example: > B.foo(x) # calls B.foo directly with instance x This is interesting, Now I kind of vaguely getting why we keep 'self' argument around in each method. Thanks you -- YYR -- http://mail.python.org/mailman/listinfo/python-list