Last active
November 9, 2017 15:17
-
-
Save filinvadim/464ecafb828bcdf977576cb3ac32714b to your computer and use it in GitHub Desktop.
Python decorators simple explanation
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 decor(func): | |
def wrapped(a, b): | |
a = 'deco' | |
b = 'rated' | |
return func(a, b) | |
return wrapped # not calling yet | |
@decor # init decor here | |
def funkcia(a, b): | |
return a + b | |
a = 1 | |
b = 2 | |
print(funkcia(a, b)) | |
# 'decorated' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment