After graduating for many years, the C + + ate the rice .... Today I'm in the tangle of what formal parameters are and what are arguments ....
The parameter that is written in the definition function is the formal parameter, because there is no memory footprint, the arguments written on the actual call are arguments, because there is memory consumption and value
Then there is the positional parameter, the variable parameter and the keyword parameter
def foo (a,*b,**c): print(a) print(b) Print(c)if__name__= ="__main__": foo (1,2,3,4,k=1,g=2)
such as the program, a,*b,**c these three are formal parameters, a,*b these two are positional arguments, **c is the keyword parameter, and *b,**c these two are mutable parameters
1,2,3,4,k=1,g=2 These are arguments, 1,2,3,4 are positional parameters; k=1,g=2 is a keyword parameter; 1 assigns a value to a;2,3,4 as a tuple to *b;k=1,g=2 pay **c in dictionary form
The output is like this.
1(2, 3, 4) {'g'k': 1}
So Fun (*args,**kwargs)
*args: (indicates that the value is passed by location in the argument, the extra value is given to args, and is rendered in tuples)
**kwargs: (indicates that the value is presented as a dictionary by keyword)
It is important to note that the keyword content passed by **kwargs can be a value (numeric, list, tuple, dictionary, etc.) and can be a function or a class
Python function parameter *args **kwargs