- To extract multiple arguments in the function parameters so can you pack them with the
*args
operator forlist
ortuples
or**kwargs
for keyword-based arguments. - To pack or unpack use the
*
or**
operator.
- Multiple arguments in the function parameters can be packed with the
*args
operator.
- Using unpacking with the
*
operator, lets you extract the first two elements of alist
while keeping the rest intact. - To add another
list
into an existinglist
, you can use the*
operator to "spread" thelist
.
- Using
**kwargs
as a function parameter will allow an arbitrary amount of keyword arguments to be passed. - Using
**<dict>
as an argument will unpack a dictionary into keyword arguments. - You can put keyword arguments in a
{}
ordict()
. - To get the values out of a dictionary, you can use the
<dict>.values()
method.
- Using
**<dict>
as an argument will unpack a dictionary into keyword arguments. - You can put keyword arguments in a
{}
ordict()
.
zip(*iterators)
can use used to transpose a nestedlist
.- To extract data from zipped iterators, you can use a for loop.
- you can also unpack zipped iterators using
*
.
[*content] = zip(iterator_1, iterator_2)
will unzip thetuple
produced byzip()
into alist
.