diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2012-12-29 19:13:45 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2012-12-29 19:13:45 (GMT) |
commit | c04957bff3a53ba3d051b7c4148a48ec5238f3cb (patch) | |
tree | 9f65af68a5cc6e41ec70ea0bdd74c8a907fe1e78 /Doc | |
parent | e912496c6025581f8f1554c9cda92ae73f2514e5 (diff) | |
download | cpython-c04957bff3a53ba3d051b7c4148a48ec5238f3cb.zip cpython-c04957bff3a53ba3d051b7c4148a48ec5238f3cb.tar.gz cpython-c04957bff3a53ba3d051b7c4148a48ec5238f3cb.tar.bz2 |
Issue #16641: Fix default values of sched.scheduler.enter arguments were modifiable.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/sched.rst | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/Doc/library/sched.rst b/Doc/library/sched.rst index f6bd43f..e73ba40 100644 --- a/Doc/library/sched.rst +++ b/Doc/library/sched.rst @@ -36,19 +36,22 @@ Example:: >>> import sched, time >>> s = sched.scheduler(time.time, time.sleep) - >>> def print_time(): print("From print_time", time.time()) + >>> def print_time(a='default'): + ... print("From print_time", time.time(), a) ... >>> def print_some_times(): ... print(time.time()) - ... s.enter(5, 1, print_time, ()) - ... s.enter(10, 1, print_time, ()) + ... s.enter(10, 1, print_time) + ... s.enter(5, 2, print_time, argument=('positional',)) + ... s.enter(5, 1, print_time, kwargs={'a': 'keyword'}) ... s.run() ... print(time.time()) ... >>> print_some_times() 930343690.257 - From print_time 930343695.274 - From print_time 930343700.273 + From print_time 930343695.274 positional + From print_time 930343695.275 keyword + From print_time 930343700.273 default 930343700.276 .. _scheduler-objects: @@ -59,7 +62,7 @@ Scheduler Objects :class:`scheduler` instances have the following methods and attributes: -.. method:: scheduler.enterabs(time, priority, action, argument=[], kwargs={}) +.. method:: scheduler.enterabs(time, priority, action, argument=(), kwargs={}) Schedule a new event. The *time* argument should be a numeric type compatible with the return value of the *timefunc* function passed to the constructor. @@ -67,8 +70,10 @@ Scheduler Objects *priority*. Executing the event means executing ``action(*argument, **kwargs)``. - *argument* must be a sequence holding the parameters for *action*. - *kwargs* must be a dictionary holding the keyword parameters for *action*. + Optional *argument* argument must be a sequence holding the parameters + for *action* if any used. + Optional *kwargs* argument must be a dictionary holding the keyword + parameters for *action* if any used. Return value is an event which may be used for later cancellation of the event (see :meth:`cancel`). @@ -80,7 +85,7 @@ Scheduler Objects *kwargs* parameter was added. -.. method:: scheduler.enter(delay, priority, action, argument=[], kwargs={}) +.. method:: scheduler.enter(delay, priority, action, argument=(), kwargs={}) Schedule an event for *delay* more time units. Other than the relative time, the other arguments, the effect and the return value are the same as those for |