Unpacking in Python 3.5
Intro
Today I want to talk about the unpacking operators(*
and **
) in python.
Basic usage
We use *
for numeric data types to indicate we want to do multiplication. However, we can also apply *
to iterable objects1, which means we want to unpack all the elements inside them.
📒The built-in iterable objects:
list
,tuple
,set
, anddict
Starred assignment/expression
In the release of python 3.0, it is shipped with powerful iterable unpacking operations2, which is called the starred assignment/expression(or parallel assignment).