June 2017
Beginner
352 pages
8h 39m
English
In production code, this function call is not particularly self documenting. We can improve that situation by naming the border argument at the call site:
>>> banner("Sun, Moon and Stars", border="*")*******************Sun, Moon and Stars*******************
In this case the message string is called a "positional argument" and the border string a "keyword argument". In a call, the positional arguments are matched up in sequence with the formal arguments declared in the function definition. The keyword arguments, on the other hand, are matched by name. If we use keyword arguments for both of our parameters, we have the freedom to supply them in any order:
>>> banner(border=".", message="Hello from Earth")................
Read now
Unlock full access