darkgaze darkgaze - 9 months ago 54
Python Question

Know if child class has implemented a parent method

I have a base class class X, and a child class Y which could reimplement or not a method from the base class X.

I pass the name of the child class as a variable to functions.

Inside those functions I need to test if that class passed has implemented or not some methods from it's base class.

(I can't use hasattr(childClassName.methodName) since it always returns True)


use to compare:

 getattr(className, 'methodName') is getattr(className, 'method')

if false, the method was overridden