def Foo( *args, **kargs ):
I know that **kargs can take multiple arguments. But, what's the dealt about function method has both *args and **kargs? How to use it in real world?
Can anyone give me an example? Thank you!
def Foo( *args, **kargs ):
I know that **kargs can take multiple arguments. But, what's the dealt about function method has both *args and **kargs? How to use it in real world?
Can anyone give me an example? Thank you!
Read the documentation: https://docs.python.org/2/tutorial/controlflow.html#keyword-arguments
*args
has no variable assigned to it. Instead you end up with args being a list of values that were placed in the function.
**kwargs
has a variable(key word) associated with it.
The order of these values don't matter. Leaving them out wont break the function unless it was created to break if specific keywords were left out. They are typically optional. The python docs explain it very well.