<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Dec 29, 2012 at 11:17 AM, serhiy.storchaka <span dir="ltr"><<a href="mailto:python-checkins@python.org" target="_blank">python-checkins@python.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><a href="http://hg.python.org/cpython/rev/1c9c0f92df65" target="_blank">http://hg.python.org/cpython/rev/1c9c0f92df65</a><br>
changeset: 81134:1c9c0f92df65<br>
branch: 3.3<br>
parent: 81132:5db0833f135b<br>
user: Serhiy Storchaka <<a href="mailto:storchaka@gmail.com">storchaka@gmail.com</a>><br>
date: Sat Dec 29 21:13:45 2012 +0200<br>
summary:<br>
Issue #16641: Fix default values of sched.scheduler.enter arguments were modifiable.<br>
<br>
files:<br>
Doc/library/sched.rst | 23 ++++++++++++++---------<br>
Lib/sched.py | 8 ++++++--<br>
Misc/NEWS | 3 +++<br>
3 files changed, 23 insertions(+), 11 deletions(-)<br>
<br>
<br>
diff --git a/Doc/library/sched.rst b/Doc/library/sched.rst<br>
--- a/Doc/library/sched.rst<br>
+++ b/Doc/library/sched.rst<br>
@@ -36,19 +36,22 @@<br>
<br>
>>> import sched, time<br>
>>> s = sched.scheduler(time.time, time.sleep)<br>
- >>> def print_time(): print("From print_time", time.time())<br>
+ >>> def print_time(a='default'):<br>
+ ... print("From print_time", time.time(), a)<br>
...<br>
>>> def print_some_times():<br>
... print(time.time())<br>
- ... s.enter(5, 1, print_time, ())<br>
- ... s.enter(10, 1, print_time, ())<br>
+ ... s.enter(10, 1, print_time)<br>
+ ... s.enter(5, 2, print_time, argument=('positional',))<br>
+ ... s.enter(5, 1, print_time, kwargs={'a': 'keyword'})<br>
... s.run()<br>
... print(time.time())<br>
...<br>
>>> print_some_times()<br>
930343690.257<br>
- From print_time 930343695.274<br>
- From print_time 930343700.273<br>
+ From print_time 930343695.274 positional<br>
+ From print_time 930343695.275 keyword<br>
+ From print_time 930343700.273 default<br>
930343700.276<br>
<br>
.. _scheduler-objects:<br>
@@ -59,7 +62,7 @@<br>
:class:`scheduler` instances have the following methods and attributes:<br>
<br>
<br>
-.. method:: scheduler.enterabs(time, priority, action, argument=[], kwargs={})<br>
+.. method:: scheduler.enterabs(time, priority, action, argument=(), kwargs={})<br>
<br>
Schedule a new event. The *time* argument should be a numeric type compatible<br>
with the return value of the *timefunc* function passed to the constructor.<br>
@@ -67,8 +70,10 @@<br>
*priority*.<br>
<br>
Executing the event means executing ``action(*argument, **kwargs)``.<br>
- *argument* must be a sequence holding the parameters for *action*.<br>
- *kwargs* must be a dictionary holding the keyword parameters for *action*.<br>
+ Optional *argument* argument must be a sequence holding the parameters<br>
+ for *action* if any used.<br>
+ Optional *kwargs* argument must be a dictionary holding the keyword<br>
+ parameters for *action* if any used.<br></blockquote><div><br></div><div>I don't see how this change improves the documentation. To keep the grammar correct and just state that the arguments are optional, I would simply replace "must be" by "is". For example:<br>
<br></div><div> *argument* is a sequence holding the parameters for *action*.<br><br></div><div>This is short, and since the function signature clearly shows that argument has a default value, I think it conveys the meaning it should.<br>
<br></div><div>Eli<br><br></div><div> </div></div></div></div>