Created on 2014-12-26 19:42 by amyluo, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (8) |
|
|
msg233114 - (view) |
Author: Amy (amyluo) |
Date: 2014-12-26 19:42 |
https://docs.python.org/3/tutorial/controlflow.html#default-argument-values def ask_ok(prompt, retries=4, complaint='Yes or no, please!'): while True: ok = input(prompt) Suggestion: change to "ok = input(prompt).lower()" in order to cover values with capitalized characters such as "Yes" or "NO". |
|
|
msg233354 - (view) |
Author: Carol Willing (willingc) *  |
Date: 2015-01-03 12:18 |
@amylou Thank you for submitting this documentation suggestion about the Python Tutorial. This tutorial section, 4.7.1 Default Argument Values, tries to show that a function can have multiple input arguments which may be given default values. While the suggestion to use lower() does offer more robust input handling, it also adds some complexity to the example by introducing another function to a possibly new user. I do believe that the 'ask_ok' function could be improved by renaming the 'complaint' argument to something more positive, perhaps 'reminder'. I would also recommend replacing the error message 'uncooperative user' to something with a softer tone, perhaps 'invalid user response'. @amyluo If you are interested in working on documentation, section 6 of the Developer Guide is a handy resource (https://docs.python.org/devguide/docquality.html). |
|
|
msg266831 - (view) |
Author: Berker Peksag (berker.peksag) *  |
Date: 2016-06-01 18:16 |
I agree with all of Carol's suggestions. Also, OSError could be replaced with a more appropriate exception such as ValueError. |
|
|
msg266833 - (view) |
Author: Fred Drake (fdrake)  |
Date: 2016-06-01 18:22 |
+1 for ValueError instead of OSError. |
|
|
msg266834 - (view) |
Author: Berker Peksag (berker.peksag) *  |
Date: 2016-06-01 18:27 |
Here is a patch. |
|
|
msg266888 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2016-06-02 16:51 |
I think the patch is okay except for the use of "-=" instead of the more verbose version. |
|
|
msg266899 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2016-06-02 18:21 |
New changeset ef800c30e28c by Berker Peksag in branch '3.5': Issue #23116: Improve ask_ok() example in the Python tutorial https://hg.python.org/cpython/rev/ef800c30e28c New changeset 174eae50b664 by Berker Peksag in branch 'default': Issue #23116: Merge from 3.5 https://hg.python.org/cpython/rev/174eae50b664 |
|
|
msg266900 - (view) |
Author: Berker Peksag (berker.peksag) *  |
Date: 2016-06-02 18:22 |
Thanks for the review. I removed the "-=" part from the patch. |
|
|
History |
|
|
|
Date |
User |
Action |
Args |
2022-04-11 14:58:11 |
admin |
set |
github: 67305 |
2016-06-02 18:22:46 |
berker.peksag |
set |
status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved |
2016-06-02 18:21:35 |
python-dev |
set |
nosy: + python-devmessages: + |
2016-06-02 16:51:11 |
benjamin.peterson |
set |
nosy: + benjamin.petersonmessages: + |
2016-06-01 18:27:34 |
berker.peksag |
set |
files: + issue23116.diffkeywords: + patchmessages: + stage: needs patch -> patch review |
2016-06-01 18:22:19 |
fdrake |
set |
nosy: + fdrakemessages: + |
2016-06-01 18:16:38 |
berker.peksag |
set |
versions: + Python 3.5, Python 3.6, - Python 3.4nosy: + berker.peksagmessages: + stage: needs patch |
2015-01-03 12🔞03 |
willingc |
set |
nosy: + docs@python, willingcmessages: + assignee: docs@pythoncomponents: + Documentation |
2014-12-26 19:42:14 |
amyluo |
create |
|