Python inspection: get only the methods defined in child class

38 Views Asked by At

I have the following class structure

class B(A):
    def __init__(self):
        inspect.getmembers(module, predicate=inspect.ismethod)

# c.py    
class C(A):
    def myfunc(self):
        pass

I want to get the list of functions defined in C in the __init__ of my class B. The problem with my inspect line is that it returns every method defined by A along with C since C inherits from A. Is there a pythonic way to exclusively get the methods directly defined in C. So only get myfunc when that line is run

0

There are 0 best solutions below