December 2018
Beginner to intermediate
796 pages
19h 54m
English
One of the recent new features, introduced in Python 3.5, is the ability to extend the iterable (*) and dictionary (**) unpacking operators to allow unpacking in more positions, an arbitrary number of times, and in additional circumstances. I'll present you with an example concerning function calls:
# additional.unpacking.pydef additional(*args, **kwargs): print(args) print(kwargs)args1 = (1, 2, 3)args2 = [4, 5]kwargs1 = dict(option1=10, option2=20)kwargs2 = {'option3': 30}additional(*args1, *args2, **kwargs1, **kwargs2)
In the previous example, we defined a simple function that prints its input arguments, args and kwargs. The new feature lies in the way we call this function. Notice how we can unpack ...
Read now
Unlock full access