Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
python decorator with parameter example
#python 3.6.9 from inspect import isfunction def wrappee(): print('wrappee() called') def f(param=''): # not used param def wrapper(wrappee): def wrapped(): print('\nprinted befor wrappee call') if isfunction(wrappee): wrappee() print('printed after wrappee call\n') return wrapped return wrapper if __name__ == '__main__': wrappee() wrapper = f('/') # decorieren und selbst zuweisen... wrappee = wrapper(wrappee) # equiv to @wrapper def wrappee: ... wrappee() # so zu lesen: f('/') returns the wrapper func; # this wrapper func will then be prefixed # with the decoration operator @ then # we get @wrapper back @f('/') # f() returns a wrapper => @f() == @wrapper def decorated_rappee(): print('decorated_wrappee() called') decorated_rappee()
run
|
edit
|
history
|
help
0
https://rextester.com/REAL13110
Hai
exception handling from user
string without space into list
10 25 58
HW Descending Order Final
Points
Hi.py
Knn (weights=distance)
linked_lists_2