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?

Asked By: Falmarri

||

Answers:

No, it doesn’t.

Answered By: nmichaels

No. It’s a completely different function. But you can try that for yourself with a dummy decorator.

Answered By: Gabi Purcaru

Think about it this way

class A(object):
    def fun(self, arg):
        return None
    fun = memoized(fun)
Answered By: kevpie
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.