This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: "Emulating callable objects" documentation misleading
Type: Stage: resolved
Components: Documentation Versions: Python 3.10, Python 3.9, Python 3.8
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: docs@python Nosy List: andrei.avk, docs@python, kamilturek, nmarrow
Priority: normal Keywords: easy

Created on 2017-09-14 17:25 by nmarrow, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg302185 - (view) Author: Nathan Marrow (nmarrow) Date: 2017-09-14 17:25
The documentation for emulating callable objects with __call__ seems to imply only positional arguments are supported. For instance, it says __call__ is "object.__call__(self[, args…])" and describes:

Called when the instance is “called” as a function; if this method is defined, x(arg1, arg2, ...) is a shorthand for x.__call__(arg1, arg2, ...).

When it should be something like (Not sure exactly what the syntax would be here):
"object.__call__(self[, args…] [,**kwargs...])"

Called when the instance is “called” as a function; if this method is defined, x(arg1, arg2, ..., arg3=arg3) is a shorthand for x.__call__(arg1, arg2, ..., arg3=arg3).
msg395292 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-06-07 22:33
I don't think the docs in current form imply keyword args are disallowed: "arguments" covers both positional and keyword args, and the call as given in example would work for both positional and keyword args (though not overriding the default value of an arg). It seems to me this can be closed.
Date User Action Args
2022-04-11 14:58:52adminsetgithub: 75653
2022-01-14 18:00:27iritkatrielsetstatus: open -> closed
resolution: works for me
stage: resolved
2021-06-07 22:33:56andrei.avksetnosy: + andrei.avk
messages: + msg395292
2021-03-14 18:04:39kamiltureksetnosy: + kamilturek
2021-03-14 17:26:40iritkatrielsetkeywords: + easy
versions: + Python 3.8, Python 3.9, Python 3.10, - Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
2017-09-14 17:25:03nmarrowcreate