June 2015
Intermediate to advanced
298 pages
7h 15m
English
Python offers even more flexibility in how we can define positional and keyword parameters for a function. The examples we've seen are all limited to a fixed and finite collection of argument values. Python allows us to write functions that have an essentially unlimited number of positional as well as keyword argument values.
Python will create a tuple of all unmatched positional parameters. It will also create a dictionary of all unmatched keyword parameters. This allows us to write functions that can be used like this:
>>> prod2(1, 2, 3, 4) 24
This function accepts an arbitrary number of positional arguments. Compare this with the prod() function shown previously. Our previous example required a ...
Read now
Unlock full access