I am in progress to learn Python. Hopefully someone points me to correct way.
This is what I’d like to do below:
def decorate(function):
def wrap_function(*args, **kwargs):
str = 'Hello!' # This is what I want
return function(*args, **kwargs)
return wrap_function
@decorate
def print_message():
# I'd like to pass 'str' as mentioned above
# to any functions' argument like below:
print(str) # 'str' is same as above
Any idea? Thanks in advance.
You can’t pass it as its own name, but you can add it to the keywords.
Alternatively you can name its own argument:
Class method: