When you are passing a value default argument, all arguments to the right of it should also have default values.
This holds true for any other programming language as well. The reason for this restriction is that otherwise, it would be impossible to determine which arguments you are trying to pass. Let's assume the following function:
def foo(first = 'default', second = 'default', third)
pass
And now we're calling it with
foo('custom_value', 'another_value')
another_value in parameters is obviously the value for the third parameter, but what parameter does the custom_value stand for? first or second? You can only guess and guessing is a really bad thing for a programming language to do, as it limits predictability for the programmer.
A way to fix that would be named parameter passes. In any other programming language like PHP, this could look like
foo($first='custom_value', 'another_value');
Now it's clear which default value you're trying to overwrite.
Python supports this syntax like that
foo(first='custom_value', third='another_value')
but for example, PHP does not (yet). So, while calling the function you need to take care of this step every time which creates unnecessary overhead to the programmer. That's why it's a good practice to have all default arguments to the right side.
Some examples of valid and invalid parameters.
Valid
def example(a = 1, b = 2):
pass
Valid
def example(a , b = 2):
pass
Invalid
def example(a = 1, b):
pass
For more information on the order of parameters in c++ look at here.
For more information on the order of parameters in python look at here.
edateandfdatepositions.