How do I override a decorated method in Python?
Question: Let's say I want to extend the following Python class, which includes a
decorator that I don't know much about:

    
    
    from somewhere import some_decorator
    
    class One(object):
        @some_decorator
        def some_method(self):
            do_something()
    

Should I decorate the overridden method or not? In other words, can I safely
do:

    
    
    class Two(One):
        def some_method(self):
            super(Two, self).some_method()
    

Or do I need to do:

    
    
    class Two(One):
        @some_decorator
        def some_method(self):
            super(Two, self).some_method()
    


Answer: Remember what the `@decorator` syntax does:

    
    
    @decorator
    def foo():
        print "foo"
    

is just syntactic sugar for

    
    
    def foo():
        print "foo"
    foo = decorator(foo)
    

Thus, the undecorated function is no longer callable by its name after it has
been decorated because its name has been assigned to something else.

This means that when you call `super(Two, self).some_method()` in the child
class, then the decorated function `some_method` in the parent will be called.

Knowing whether or not you also need to decorate the child overridden method
entirely depends on what you want to do and what the decorator does. But know
that if you call `super(Two, self).some_method()`, then you will call the
decorated function.

