DeveloperBreeze

Python Decorator to Uppercase Result

python
# 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')

Related Posts

More content you might like

Code
javascript

JavaScript Prime Number Check

No preview available for this content.

Jan 26, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!