December 2018
Beginner to intermediate
796 pages
19h 54m
English
Keyword arguments are assigned by keyword using the name=value syntax:
# arguments.keyword.pydef func(a, b, c): print(a, b, c)func(a=1, c=2, b=3) # prints: 1 3 2
Keyword arguments are matched by name, even when they don't respect the definition's original position (we'll see that there is a limitation to this behavior later, when we mix and match different types of arguments).
The counterpart of keyword arguments, on the definition side, is default values. The syntax is the same, name=value, and allows us to not have to provide an argument if we are happy with the given default:
# arguments.default.pydef func(a, b=4, c=88): print(a, b, c)func(1) # prints: 1 4 88func(b=5, a=7, c=9) # prints: 7 5 9func(42, ...Read now
Unlock full access