I've been learning python recently and I'm a little confused to why people name their parameters when calling the function their naming the parameters to?
Take this code for starter
def my_funcation(greeting = 'Hello', name = 'Guest'): return f'{greeting}, {name}. How are you?' print(my_function('Yo', name = 'Adam')) It all looks good, but there's one part I don't get. Why do people specifiy the parameter name their assigning to? Is this like a convention or is it a rule to write good code?
Why can't we just write this..
def my_funcation(greeting = 'Hello', name = 'Guest'): return f'{greeting}, {name}. How are you?' print(my_function('Yo', 'Adam')) IMO, the second one is better, incase the parameter name ever changes.
namefor example, you would have to explicitly usemy_function(name='Chris'), whilegreetingwould default to'Hello'