PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# from code by Sharpneli in answer to post by Ketan Lalcheta
#what if i need both functions with and without decorator
# Sololearn external module installer
def install(package):
__import__('os').system(f"pip3 install -qq --target='/usercode' {package}")
install('undecorated')
import functools, inspect
from undecorated import undecorated
def decorator(func):
#use functools.wraps
@functools.wraps(func) #try comenting this out
def wrapper(*args, **kwargs):
print("Hi from decorator")
print("before func call")
return func(*args, **kwargs)
print("after func call")
return wrapper
@decorator
def myfunc():
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run