Do overridden methods inherit decorators in python?

Falmarri picture Falmarri · Dec 3, 2010 · Viewed 7.9k times · Source

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?

Answer

kevpie picture kevpie · Dec 3, 2010

Think about it this way

class A(object):
    def fun(self, arg):
        return None
    fun = memoized(fun)