Horje
python star sign before list Code Example
python star sign before list
Inside a function header:

* collects all the positional arguments in a tuple.

** collects all the keyword arguments in a dictionary.

>>> def functionA(*a, **kw):
       print(a)
       print(kw)

>>> functionA(1, 2, 3, 4, 5, 6, a=2, b=3, c=5)
(1, 2, 3, 4, 5, 6)
{'a': 2, 'c': 5, 'b': 3}


In a function call:

* unpacks a list or tuple into position arguments.

** unpacks a dictionary into keyword arguments.
>>> lis=[1, 2, 3, 4]
>>> dic={'a': 10, 'b':20}
>>> functionA(*lis, **dic)  #it is similar to functionA(1, 2, 3, 4, a=10, b=20)
(1, 2, 3, 4)
{'a': 10, 'b': 20}




Python

Related
what is norways politics Code Example what is norways politics Code Example
key item loop list python Code Example key item loop list python Code Example
not en python Code Example not en python Code Example
python create new folder in path that don't exist Code Example python create new folder in path that don't exist Code Example
pandas fill nan methods Code Example pandas fill nan methods Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9