June 2019
Beginner to intermediate
770 pages
19h 24m
English
In order to write a multi-strategy initialization, it can seem helpful to give up on specific named parameters. This leads to trying to use the **kw construct to take only named arguments. This design has the advantage of being very flexible, but the disadvantage of bypassing automated type checking. It requires a great deal of documentation explaining the variant use cases.
Instead of collecting all named parameters using the ** construct, it's often helpful to use a standalone * construct. When we write def f(a: int, b: int, *, c: int), we're expecting two positional argument values, and the third value must be provided by name. We'd use this function as f(1, 2, c=3). This provides for explicit names ...
Read now
Unlock full access