# Decorator function to uppercase the result of another function
def uppercase_decorator(function):
def wrapper(*args, **kwargs):
result = function(*args, **kwargs)
return result.upper()
return wrapper
# Function decorated with the uppercase_decorator
@uppercase_decorator
def greet(name):
return f'Hello, {name}'
# Usage: Call the decorated function
result = greet('Alice')
code
Python Decorator to Uppercase Result
This Python code defines a decorator uppercase_decorator that can be applied to functions. The decorator modifies the result of the decorated function by converting it to uppercase. The greet function is then decorated with @uppercase_decorator, and its result is stored in the variable result. The comments provide explanations for each part of the code.
Decorator
Function
Uppercase