Use a variadic positional parameter when a function should accept an unknown number of positional values. Python writes this parameter as *args; inside the function, args is a tuple. section 7.0 section 11.23
Reimplementing sum
A focused exercise is to write mysum(1, 2, 3) and mysum(10, 20, 30, 40, 50), adding the values without calling the built-in sum. Iterate over args rather than indexing it: the parameter is intended for an unknown number of values. section 2.6 section 7.3
Choose parameter types according to the function’s intended call pattern:
- Use *args when callers may provide any number of positional values and the implementation will process them as a sequence, commonly with a for loop. section 7.3
- Use a default parameter when a particular argument is optional and has a natural fallback, such as content=''. section 7.3
- Use **kwargs for arbitrary name=value arguments; Python collects them separately in a dictionary rather than the positional tuple. section 7.0 section 7.3







