|
|
|
|
|
by rand_r
2561 days ago
|
|
In Python 2, if you need to, you can force people to use kwargs by defining the function in the form of def f(*args, **kwargs):
and then making sure any params you use in the function come from kwargs, and raising an error if args is non-empty.Python 3 has a nicer way of doing the same thing, that I can’t remember. (Sourced from the book “Effective Python: 59 Specific Ways to Write Better Python”.) |
|