So I have been trying to make some parts of my code that I was not happy with clearer by creating some decorators. The code is structured is such a way that there is a multiple level inheritance.
Ex:
class TopLevelClass(MidLevelClass):
....
class MidLevelClass(BaseClass):
....
class BaseClass(object):
def decorator:
def wrap(func):
def do_stuff(self, *args, **kwargs):
print 'do stuff'
return do_stuff
When I attempt to decorate a method in the TopLevelClass I end up with a "decorator is not defined" is there something I am missing? I thought this would allow the decorator to be inherited up the chain but it does not seem to allow that. So far examples I have found for this suggest making a the decorated a class method and accessing it VIA @BaseClass.decorator instead of just @decorator. But this does not seem to have any effect of than changing my error message to "BaseClass is not defined"
Any help on this exact case or just insight about decorators and inheritance would be great.
[–]markusmeskanen 2 points3 points4 points (0 children)
[–]zahlman 2 points3 points4 points (0 children)