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.

classification
Title: Add a glossary entry for "callable" objects
Type: Stage: resolved
Components: Documentation Versions: Python 3.9, Python 3.8, Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Delgan, docs@python, rhettinger
Priority: normal Keywords:

Created on 2019-11-23 09:10 by Delgan, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg357366 - (view) Author: Delgan (Delgan) * Date: 2019-11-23 09:10
Hi.

Quick use case explanation about this: I would like to document my function, stating that it accepts any "callable" object and linking to a proper definition of such object.

For example, I'm already doing this when my function accepts a "file object". There exists no such type I can link to, so I link to the glossary definition: https://docs.python.org/3/glossary.html#term-file-object

I could link to the "callable()" built-in but than does not reflect well the expected *type* of the argument. For now, I define the argument as a "function" ( https://docs.python.org/3/glossary.html#term-function ) but this is too restrictive.

The definition for "callable" would be pretty straightforward, just mentioning it should implement "__call__", also linking to "emulating callable object" ( https://docs.python.org/3/reference/datamodel.html#emulating-callable-objects ) and / or the "callable()" builtin ( https://docs.python.org/3/library/functions.html#callable ).
msg357368 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-11-23 09:32
-1 I don't think this would be an improvement.  We already have a builtin callable() function documented, and we have the documented Callable() abstract base class, and the __call__ method is documented in the library reference.  I don't we need yet another entry describing a straight-forward concept.  Also I don't think we should litter the rest of docs with a link to a term-callable everytime we use the wordl.
msg357371 - (view) Author: Delgan (Delgan) * Date: 2019-11-23 10:10
I agree, it's straightforward. I just thought it could be useful to have a proper definition in the official documentation.

For example, this question on StackOverflow actually received many views: https://stackoverflow.com/questions/111234/what-is-a-callable

What do you think is the best documentation entry I can link to while mentioning a "callable" type? Just the builtin "callable()"? The `collections.abc.Callable` is interesting but does not look very appropriate for basic functions.
msg357374 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-11-23 10:42
I suggest linking to the built-in callable() function:  https://docs.python.org/3/library/functions.html#callable
History
Date User Action Args
2022-04-11 14:59:23adminsetgithub: 83081
2019-11-23 10:42:23rhettingersetstatus: open -> closed
resolution: rejected
messages: + msg357374

stage: resolved
2019-11-23 10:10:40Delgansetmessages: + msg357371
2019-11-23 09:32:53rhettingersetnosy: + rhettinger
messages: + msg357368
2019-11-23 09:10:17Delgancreate