Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e4c997e3
Commit
e4c997e3
authored
Jun 02, 2016
by
Berker Peksag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #23116: Improve ask_ok() example in the Python tutorial
parent
ffd866fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
Doc/tutorial/controlflow.rst
Doc/tutorial/controlflow.rst
+3
-3
No files found.
Doc/tutorial/controlflow.rst
View file @
e4c997e3
...
@@ -361,7 +361,7 @@ The most useful form is to specify a default value for one or more arguments.
...
@@ -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
This creates a function that can be called with fewer arguments than it is
defined to allow. For example::
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:
while True:
ok = input(prompt)
ok = input(prompt)
if ok in ('y', 'ye', 'yes'):
if ok in ('y', 'ye', 'yes'):
...
@@ -370,8 +370,8 @@ defined to allow. For example::
...
@@ -370,8 +370,8 @@ defined to allow. For example::
return False
return False
retries = retries - 1
retries = retries - 1
if retries < 0:
if retries < 0:
raise
OSError('uncooperative user
')
raise
ValueError('invalid user response
')
print(
complaint
)
print(
reminder
)
This function can be called in several ways:
This function can be called in several ways:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment