Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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}
Comment

PREVIOUS NEXT
Code Example
Python :: regex emaple py 
Python :: youtube view bot python code pastebin 
Python :: discord.py custom status 
Python :: bill wiliams fractal python pandas 
Python :: is complex datatype immutable in python 
Python :: how to update phyton to phycram 
Python :: linear zoeken python 
Python :: var person 
Python :: spark group by alias 
Python :: how to export schema in graphene django 
Python :: create model object from dictionary 
Python :: how to convert array value to integer in python 
Python :: Python Print Variable Using the + operator to join variables 
Python :: list tuple dictionary, 
Python :: how to print a text in python 
Python :: how to get the remainder of a number when dividing in python 
Python :: computecost pyspark 
Python :: Tuples as return values 
Python :: what is proc file 
Python :: uneven chunks of array slices 
Python :: Multiple sub in single regex 
Python :: onetomany field 
Python :: how to create dll from java code 
Python :: what is type 
Python :: python get next item from generator 
Python :: python csv row index is empty 
Python :: snipe cmd python.py 
Python :: random email generator python 
Python :: shape of a dataframe 
Python :: python multiprocessing queue 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =