diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2016-06-02 18:31:19 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2016-06-02 18:31:19 (GMT) |
commit | 0a5120e457107bc4288a60cf81b8fe0911958fc2 (patch) | |
tree | d1531b5063c77ac6a9379ab776e6f685aed08207 /Doc/tutorial | |
parent | e26da7c03a714faa115fe6b708ef0730119aa4b3 (diff) | |
download | cpython-0a5120e457107bc4288a60cf81b8fe0911958fc2.zip cpython-0a5120e457107bc4288a60cf81b8fe0911958fc2.tar.gz cpython-0a5120e457107bc4288a60cf81b8fe0911958fc2.tar.bz2 |
Issue #23116: Improve ask_ok() example in the Python tutorial
Diffstat (limited to 'Doc/tutorial')
-rw-r--r-- | Doc/tutorial/controlflow.rst | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index 65f83bf..ddc0855 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -361,7 +361,7 @@ The most useful form is to specify a default value for one or more arguments. This creates a function that can be called with fewer arguments than it is defined to allow. For example:: - def ask_ok(prompt, retries=4, complaint='Yes or no, please!'): + def ask_ok(prompt, retries=4, reminder='Please try again!'): while True: ok = input(prompt) if ok in ('y', 'ye', 'yes'): @@ -370,8 +370,8 @@ defined to allow. For example:: return False retries = retries - 1 if retries < 0: - raise OSError('uncooperative user') - print(complaint) + raise ValueError('invalid user response') + print(reminder) This function can be called in several ways: |