Nested Decorator for Uppercase Conversion

  • Share this:

Code introduction


Create a nested function where the outer function is a decorator and the inner function is a decorator that converts the result to uppercase, and returns the converted result of the original parameters.


Technology Stack : Decorator, function nesting, built-in method upper()

Code Type : Function

Code Difficulty : Intermediate


                
                    
def aaaaaaa(arg1, arg2):
    def bbbbbbb(func):
        def ccccccc(*args, **kwargs):
            return func(*args, **kwargs)
        return ccccccc
    def ddddddd(func):
        def eeeeeee(*args, **kwargs):
            result = func(*args, **kwargs)
            return result.upper()
        return eeeeeee
    return bbbbbbb(dddddddd(arg2))