1

I have a base class which I have made abstract.

class X(metaclass=ABCMeta):

   @abstractmethod
   @tornado.gen.coroutine
   def cc(self):
      # do stuff

What should the order of the decorators go in? And does it matter?

johhny B
  • 1,342
  • 1
  • 18
  • 37

1 Answers1

3

The order of stacked function decorators usually does matter for correct interpretation (based on the flow of your program), and in this case it is stated explicitly in the docs:

When abstractmethod() is applied in combination with other method descriptors, it should be applied as the innermost decorator...

So in your case, you should swap the order to make it the innermost decorator.

class X(metaclass=ABCMeta):

    @tornado.gen.coroutine
    @abstractmethod
    def cc(self):
       # do stuff
miradulo
  • 28,857
  • 6
  • 80
  • 93