Slide 11
Slide 11 text
The Power of Keyword Arguments
Keyword Only Args (Python 3 Only)
Force callers to supply keyword args.
Keyword Only Args
from typing import List
def summation(numbers: List, *, modulo: int = 1) -> int:
"""Calculate summation of numbers"""
total = 0
for number in numbers:
total = total + number
return total % modulo
print(summation([1, 2, 3, 4, 5], modulo=5)) # 0
print(summation([1, 2, 3, 4, 5], 5)) # raise TypeError
11 / 15