Do overridden methods inherit decorators in python?
Question:
Just like the title says, do overridden methods inherit decorators?
class A:
@memoized
def fun(self, arg):
return None
class B(A):
def fun(self, arg):
#computations
return something
so does B.fun() maintain the decorator?
Answers:
No, it doesn’t.
No. It’s a completely different function. But you can try that for yourself with a dummy decorator.
Think about it this way
class A(object):
def fun(self, arg):
return None
fun = memoized(fun)
Just like the title says, do overridden methods inherit decorators?
class A:
@memoized
def fun(self, arg):
return None
class B(A):
def fun(self, arg):
#computations
return something
so does B.fun() maintain the decorator?
No, it doesn’t.
No. It’s a completely different function. But you can try that for yourself with a dummy decorator.
Think about it this way
class A(object):
def fun(self, arg):
return None
fun = memoized(fun)