E
Edward Diener
In the tutorial on functions there are sections on default arguments and
keyword arguments, yet I don't see the syntactic difference between them.
For default arguments the tutorial shows:
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
while for keyword arguments the tutorial shows:
def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
The syntax 'keyword = value' is used for both as far as I can see. How does
one distinguish between them or are they both part of the same combined
concept, which is: if one calls the function with less than the required
number of arguments but does specify keyword values, those values are used,
else the defaults are supplied. Or is there really a syntactic difference
between default arguments and keyword arguments which I have missed above ?
keyword arguments, yet I don't see the syntactic difference between them.
For default arguments the tutorial shows:
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
while for keyword arguments the tutorial shows:
def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
The syntax 'keyword = value' is used for both as far as I can see. How does
one distinguish between them or are they both part of the same combined
concept, which is: if one calls the function with less than the required
number of arguments but does specify keyword values, those values are used,
else the defaults are supplied. Or is there really a syntactic difference
between default arguments and keyword arguments which I have missed above ?