Python : *args vs **kwargs in python.

 


Both *args and **kwargs are are special syntaxes used to represent multiple arguments. Both *args and **kwargs are used by convention, a diffrent name can be used for both. 



Arguments are always passed as reference in python, 

Example: Since arguments are always passed as reference in python we can notice a change in argument value within the function will be permanently impacted to that corresponding variable or function.

def appendNumber(arr):
   arr.append(4)
arr = [1, 2, 3]
print(arr)  #Output: => [1, 2, 3]
appendNumber(arr)
print(arr)  #Output: => [1, 2, 3, 4]


Comments