Re: Multiple hierarchie and method overloading
Philippe Martin wrote: Hi, I have something like this: Class A: def A_Func(self, p_param): . Class B: def A_Func(self): . Class C (A,B): A.__init__(self) If that's really your code, you should have an exception right here. Else, please post real code. B.__init__(self) . self.A_Func() #HERE I GET AN EXCEPTION ... takes at least 2 arguments (1 given). I renamed A_Func(self) to fix that ... but is there a cleaner way around ? Perhaps should you read these texts: http://diveintopython.org/object_oriented_framework/defining_classes.html http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm http://docs.python.org/tut/node11.html -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple hierarchie and method overloading
Philippe Martin wrote: Hi, I have something like this: Class A: def A_Func(self, p_param): . Class B: def A_Func(self): . Class C (A,B): A.__init__(self) B.__init__(self) . self.A_Func() #HERE I GET AN EXCEPTION ... takes at least 2 arguments (1 given). Ho, yes, also: A.A_Func() really takes 2 arguments (self, and p_param). When called from an instance of A, the first argument (ie: self) will be automagically feed with the instance itself - but you still have to pass the second one. I renamed A_Func(self) to fix that ... but is there a cleaner way around ? Yes : passing the second argument. -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple hierarchie and method overloading
Thanks, I'll try that. Philippe Ben Cartwright wrote: Philippe Martin wrote: I have something like this: Class A: def A_Func(self, p_param): . Class B: def A_Func(self): . Class C (A,B): A.__init__(self) B.__init__(self) . self.A_Func() #HERE I GET AN EXCEPTION ... takes at least 2 arguments (1 given). I renamed A_Func(self) to fix that ... but is there a cleaner way around ? When using multiple inheritence, the order of the base classes matters! E.g.: class A(object): def f(self): print 'in A.f()' class B(object): def f(self): print 'in B.f()' class X(A, B): pass class Y(B, A): pass x = X() x.f() in A.f() y = Y() y.f() in B.f() If you want to call B.f() instead of A.f() for an X instance, you can either rename B.f() like you've done, or do this: B.f(x) in B.f() --Ben -- http://mail.python.org/mailman/listinfo/python-list
Multiple hierarchie and method overloading
Hi, I have something like this: Class A: def A_Func(self, p_param): . Class B: def A_Func(self): . Class C (A,B): A.__init__(self) B.__init__(self) . self.A_Func() #HERE I GET AN EXCEPTION ... takes at least 2 arguments (1 given). I renamed A_Func(self) to fix that ... but is there a cleaner way around ? Regards, Philippe -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple hierarchie and method overloading
Philippe Martin wrote: I have something like this: Class A: def A_Func(self, p_param): . Class B: def A_Func(self): . Class C (A,B): A.__init__(self) B.__init__(self) . self.A_Func() #HERE I GET AN EXCEPTION ... takes at least 2 arguments (1 given). I renamed A_Func(self) to fix that ... but is there a cleaner way around ? When using multiple inheritence, the order of the base classes matters! E.g.: class A(object): def f(self): print 'in A.f()' class B(object): def f(self): print 'in B.f()' class X(A, B): pass class Y(B, A): pass x = X() x.f() in A.f() y = Y() y.f() in B.f() If you want to call B.f() instead of A.f() for an X instance, you can either rename B.f() like you've done, or do this: B.f(x) in B.f() --Ben -- http://mail.python.org/mailman/listinfo/python-list