[issue6570] Tutorial clarity: section 4.7.2, parameters and arguments

Terry J. Reedy report at bugs.python.org
Wed Nov 9 04:51:46 CET 2011


Terry J. Reedy <tjreedy at udel.edu> added the comment:

>Would adding 'required' before 'positional' and 'optional' before 'keyword arguments' be ok?

No! What is false in the original and the above is the equation and confusion of 'required' with 'positional' and 'optional' with 'keyword'. Required/optional is an argument property for all calls to a function as determined by the function definition.  Position/keyword is an argument property for each particular call as determined by the call itself (or the programmer thereof). The two contrasts are logically independent even if there is empirical correlation in the practice of some programmers. All arguments for parrot, both the required voltage argument and the three optional arguments, can be passed by either position or keyword. This is shown by the examples that pass both types of arguments both ways.

(Similarly, both required and optional args can be defined as (pass-by-)keyword-only arguments,
  >>> def f(a,b=2,*,c,d=4): return a,b,c,d
  >>> f(1,c=3)
  (1, 2, 3, 4)
though such possibilities are not relevant here.)

>> An argument for voltage is required, the other three are optional.

Prefix the above with "When calling this function,".

> That part refers to the function signature, not the function call.

I was specifically referring to calls. All parameters in a signature require an argument. A function signature may (optionally ;-) define an argument for any parameter as optional *in function call expressions* by giving an alternate default argument for the parameter.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6570>
_______________________________________


More information about the Python-bugs-list mailing list