Nested Function Sum and String Representation

  • Share this:

Code introduction


Defined a nested function that can accept three arguments and return their sum. It also overrides the `__str__` method to return the string representation of the arguments.


Technology Stack : Built-in functions and methods

Code Type : Function

Code Difficulty : Intermediate


                
                    
def aaaa(arg1, arg2, arg3):
    def __init__(self, arg1, arg2, arg3):
        self.arg1 = arg1
        self.arg2 = arg2
        self.arg3 = arg3

    def __call__(self):
        return self.arg1 + self.arg2 + self.arg3

    def __str__(self):
        return f"{self.arg1} + {self.arg2} + {self.arg3}"