[issue24256] threading.Timer is not a class

New submission from John Runyon: the documentation (https://docs.python.org/2/library/threading.html#threading.Timer) lists "threading.Timer" as a class. It is not, which means that (for example) you can not use it in isinstance(). "threading._Timer" is a class. "threading.Timer(...).__class__" is a class. "threading.Timer" is a function.
import threading threading.Timer <function Timer at 0x7f99cae23848>
---------- assignee: docs@python components: Documentation messages: 243735 nosy: docs@python, jrunyon priority: normal severity: normal status: open title: threading.Timer is not a class versions: Python 2.7 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue24256> _______________________________________

Ned Deily added the comment: This is really a duplicate of Issue5831 which ended up being closed as a duplicate of Issue10968. The resolution of the latter issue was to change threading.Timer in Python 3.3 to actually be a class, a new feature. But it appears that along the way the issue of correcting the documentation for 2.7 was never addressed. Perhaps you could propose wording for a documentation patch? ---------- nosy: +ned.deily stage: -> needs patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue24256> _______________________________________

John Runyon added the comment: Concise documentation isn't my forte, but my confusion would've been avoided with a note that "for historical reasons, threading.Timer is actually a factory function for the underlying class threading._Timer" or something along those lines. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue24256> _______________________________________

Angad Singh added the comment: Taking a stab at this. Attached patch. ---------- keywords: +patch nosy: +angad Added file: http://bugs.python.org/file39858/function_threading_timer.diff _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue24256> _______________________________________

R. David Murray added the comment: Thanks, but we don't want to document an "internal only" name (which is what the leading underscore means in this case). It might be desirable to note that the name is a class in python3, I'm not sure. ---------- nosy: +r.david.murray _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue24256> _______________________________________

John Runyon added the comment: New proposed patch. I understand not wanting to document an "internal only name", except that in this case it rather needs to be documented. I would strongly prefer Angad's patch to mine because you do, at times, need to know the actual name of the class being used -- and the documentation should not force people to dig through the source code to find that. ---------- Added file: http://bugs.python.org/file41062/timer.diff _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue24256> _______________________________________

Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment: Python 2.7 is no longer supported. ---------- nosy: +serhiy.storchaka resolution: -> out of date stage: needs patch -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue24256> _______________________________________
participants (5)
-
Angad Singh
-
John Runyon
-
Ned Deily
-
R. David Murray
-
Serhiy Storchaka