You can define a keyword-only function in python by using a *
(everything afterwards will be keyword-only). This can make the meaning of function arguments much clearer, compare:
my_function(my_data, False, 4, 16, None)
and:
my_function(my_data, shuffle=False, num_workers=4, batch_size=16, output_file=None)
You'd define this as:
def my_function(my_data, *, shuffle, num_workers, batch_size, output_file):
...
You can also have positional-only arguments, but you probably don't need to do that.
Via: Richard