August 2019
Beginner
482 pages
12h 56m
English
In some cases, we don't know beforehand the exact number of arguments that will be passed to the function. For example, the print function will take and print any number of arguments. The same can be done for our custom function, using *args. In this case, args itself is not a keyword, but rather a conventional name of all those multiple values, packed – technically, you can use any name you want. All of the actual job is done by the asterisks – it indicates that all passed values will be packed into one tuple (we'll discuss tuples in Chapter 4, Data Structures). Within the function's scope, you can use args as a tuple variable, or pass it using the same asterisks.
Similarly, in some cases, those multiple values ...