Alter default parameters of a function in a decorator in Python -
I have a decorator to change the string argument passed in the function:
def decorator ( Fn): Def Cover (* Args): replacement = list () for arg in arg: new_item = arg + "!!!" Restriction .append (new_item) args = tuple (replacement) print fn (* args) return cover
I have a generic parameter that gives me the decorator
:
def f1 (arg1 = "hello world"): return arg1
to my surprise
Decorator (F) 1) () # Returning a default Hello World
using the default argument
I did some research, and found out that I also learned that the default values parameters are stored in the .func_defaults
property.
question
function passes in f1
wrapper by * args
and changes to expected form ?
Comments
Post a Comment