Last active
December 17, 2015 17:49
-
-
Save Abhishek-Srivastava/5648431 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def entryExit(f): | |
def new_f(): | |
print "Entering", f.__name__ | |
f() | |
print "Exited", f.__name__ | |
new_f.__name__ = f.__name__ | |
return new_f | |
@entryExit | |
def func1(): | |
print “inside func1() | |
@entryExit | |
def func2(): | |
print “inside func2()”func1() | |
func2() | |
print (“*”)*40 | |
#without decorator | |
def func1_wd(): | |
print “inside func1()” | |
def func2_wd(): | |
print “inside func2()” | |
fwd1 = func1_wd | |
fwd2 = func2_wd | |
entryExit(fwd1)() | |
entryExit(fwd2)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment