Code as follows
def my_dec(func):
def wrap(w):
t = func(w)
return t * 4
return wrap
@my_dec
def testing(n):
return n
new = testing(3)
print(new) # This prints 12
This example is working fine, but now I'm trying to add the following to the decorator @my_dec(100)
, I need to multiply the given number by 100.
When I try this
@my_dec(100)
def testing(n):
return n
I get the following error:
Traceback (most recent call last):
File "./deco2", line 10, in <module>
@my_dec(100)
File "./deco2", line 5, in wrap
t = func(w)
TypeError: 'int' object is not callable
How can I pass the 100
to the decorator?