Default arguments

A parameter can have a default value: def greet(name, greeting="Hello"). Callers can leave it out, or pass a new value to override it.

Parameters with defaults must come after the ones without. def f(a=1, b) is a SyntaxError.

The surprise: the default is evaluated once, when Python runs the def line, not each time you call the function. For numbers and strings that never matters. In the program, stamp uses time.time() as a default, and every call prints the same moment, because the clock was read only once.

The fix is the same as for the next page: default to None and compute the real value inside the function.

Run it, then change stamp so each call prints a fresh time.