DeveloperBreeze

Python Decorator to Uppercase Result

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

Continue Reading

Discover more amazing content handpicked just for you

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. Start the discussion!