28. Clarify function calls with keyword arguments
When passing in values/arguments to a method, try to associate the values with the argument names.
28.1. Don’t do this
1def format_information(first_name, last_name, age):
2 return '{} {} is {} years old'.format(first_name, last_name, age)
3
4format_information('John', 'Doe', 28)
28.2. Do this
1def format_information(first_name, last_name, age):
2 return '{} {} is {} years old'.format(first_name, last_name, age)
3
4format_information(first_name='John', last_name='Doe', age=28)
1def format_information(first_name, last_name, age):
2 return '{} {} is {} years old'.format(first_name, last_name, age)
3
4format_information(**{
5 'first_name': 'John',
6 'last_name': 'Doe',
7 'age': 28
8})