python-distilled icon indicating copy to clipboard operation
python-distilled copied to clipboard

5.16 `debug` should be after the `/` separator

Open kemar opened this issue 3 years ago • 1 comments

Section 5.16, pg. 121, in the positional-only arguments example, debug should be after the / separator:

The signature is:

-def after(seconds, func, debug=False, /, *args, **kwargs):
+def after(seconds, func, /, *args, debug=False, **kwargs):

kemar avatar Feb 07 '22 11:02 kemar

Not a typo, but still questionable. The example is meant to illustrate how keyword arguments using **kwargs can be safely accepted without conflicting with other already defined arguments. If anything, a comment about debug no longer being possible to pass as a keyword argument should be added somewhere. Or the example should be rewritten to not include the debug argument.

dabeaz avatar Mar 09 '22 12:03 dabeaz

If not putting debug=True after the / separator, the function call in Section 5.16 would failed with the error,

after(1, add, 1, y=2) TypeError: add() missing 1 required positional argument: 'x'

1 has been assigned to debug, not x.

physadair avatar Apr 27 '24 09:04 physadair

Added to errata. Thanks!

dabeaz avatar May 23 '24 14:05 dabeaz