I was playing with decorators, came up with following code.
def first(fn):
def wrapper():
print 'Before First'
fn()
return wrapper
def second(fn):
def wrapper():
print 'Before Second'
fn()
return wrapper
@second
@first
def fn():
print 'The Original Function'
fn()
I get output as below
Before Second
Before First
The Original Function
I really don't get the order. I have read somewhere that decorator gets called in reverse order, I mean first should be called first and second should be called second. But the output suggests otherwise. What is happening here??