Decorators run before function it is decorating is called?

后端 未结 4 1829
逝去的感伤
逝去的感伤 2020-12-06 02:13

As an example:

def get_booking(f=None):
    print "Calling get_booking Decorator"
    def wrapper(request, **kwargs):
        booking = _get_booking         


        
4条回答
  •  星月不相逢
    2020-12-06 02:24

    A decorator is called as soon as the decorated function is defined. It is equivalent to writing something like this:

    def __do_stuff(...):
        ...
    
    do_stuff = get_booking(__do_stuff)
    

提交回复
热议问题