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: Doc mistake : threading.Timer is *not* a class
Type: Stage: resolved
Components: Documentation, Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder: threading.Timer should be a class so that it can be derived
View: 10968
Assigned To: Nosy List: Martijn.van.Oosterhout, eric.araujo, georg.brandl, humitos, keldonin, loewis, maxenced, r.david.murray
Priority: low Keywords: easy, patch

Created on 2009-04-24 13:42 by maxenced, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
threading.Issue.5831.patch humitos, 2009-09-04 17:42 review
Messages (7)
msg86409 - (view) Author: Maxence (maxenced) Date: 2009-04-24 13:42
In the documentation, the Timer() function of the threading class is
described as a class. however, it's a function :

>>> import threading
>>> threading.Timer
<function Timer at 0x967495c>


msg86413 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-04-24 15:00
The Timer function is a simple wrapper for creating an instance of the
_Timer class.

The Timer class was proposed in Issue428326 by Itamar and applied
by Martin in r22972.  In the original patch the class was exposed as
Timer.  Martin's commit introduced the Timer function and _Timer class
name.  The documentation provided by Itamar was not updated to match.

The change would appear to intentionally make it difficult to create
Timer subclasses.

The Timer function/class was added in 2001 and there are no complaints
that Thread can't be subclassed in the tracker.  So perhaps a doc patch
is appropriate...but that would leave Timer with a name that is not PEP
8 compliant.

I think I'd prefer deleting the function and naming the class Timer,
so that it has a PEP 8 compliant name. It seems unlikely that any user
code would depend on Timer being a function.

Martin, do you have any memory of why you made Timer a function?  Was it
just that it would be pretty pointless to subclass it?
msg92260 - (view) Author: Manuel Kaufmann (humitos) * Date: 2009-09-04 17:42
I deleted this function and I renamed the class _Timer to Timer. I
attached the patch
msg121387 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-17 22:31
Nearly all classes in threading uses this function/class indirection, which I don’t understand (except for RLock, which is a factory function).
msg126848 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-01-22 18:32
Explanation has been provided on #10968, and hopefully the code will be cleaned up.  Closing as superseded.
msg128587 - (view) Author: Martijn van Oosterhout (Martijn.van.Oosterhout) Date: 2011-02-15 12:07
Note this is a behaviour change. Under the old scheme (Foo is a class)

Foo.timerclass = Timer

created a method, whereas now it will just assign the class as an attribute. To work around this you had to use _Timer. Will that dummy class remain as an alias to avoid breaking code (in 2.7 at least)?
msg128595 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-02-15 13:23
Discussion should be moved to #10968, please.
Date User Action Args
2022-04-11 14:56:48adminsetgithub: 50081
2011-02-15 13:23:18r.david.murraysetnosy: loewis, georg.brandl, humitos, eric.araujo, keldonin, r.david.murray, maxenced, Martijn.van.Oosterhout
messages: + msg128595
2011-02-15 12:07:30Martijn.van.Oosterhoutsetnosy: + Martijn.van.Oosterhout
messages: + msg128587
2011-01-22 18:32:29eric.araujosetstatus: open -> closed
nosy: loewis, georg.brandl, humitos, eric.araujo, keldonin, r.david.murray, maxenced
messages: + msg126848

superseder: threading.Timer should be a class so that it can be derived
resolution: duplicate
stage: resolved
2010-11-17 22:31:21eric.araujosetversions: + Python 3.2, - Python 2.6, Python 3.0
nosy: + eric.araujo

messages: + msg121387

assignee: docs@python ->
2010-10-29 10:07:21adminsetassignee: georg.brandl -> docs@python
2009-09-04 17:42:40humitossetfiles: + threading.Issue.5831.patch

nosy: + humitos
messages: + msg92260

keywords: + patch
2009-04-25 07:38:37keldoninsetnosy: + keldonin
2009-04-24 15:00:04r.david.murraysetpriority: low

components: + Library (Lib)
versions: - Python 2.5
keywords: + easy
nosy: + loewis, r.david.murray

messages: + msg86413
2009-04-24 13:42:36maxencedcreate