Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions examples/generator_delegation_correct.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ def footrace():
The footrace generator will start over if it is sent
a string 'fault'
"""
started = False
while not started:
while True:
status = yield 'On your marks.'
if status == 'fault':
continue
status = yield 'Set.'
if status == 'fault':
continue
yield 'Go!'
started = True
break
5 changes: 2 additions & 3 deletions examples/generator_delegation_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ def footrace():
a string 'fault'. Keeps track of faults and reutrns the
total.
"""
started = False
faults = 0
while not started:
while True:
status = yield 'On your marks.'
if status == 'fault':
faults = faults + 1
Expand All @@ -39,6 +38,6 @@ def footrace():
faults = faults + 1
continue
yield 'Go!'
started = True
break

return faults
5 changes: 2 additions & 3 deletions examples/generator_delegation_wrong.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ def footrace():
The footrace generator will start over if it is sent
a string 'fault'
"""
started = False
while not started:
while True:
status = yield 'On your marks.'
if status == 'fault':
continue
status = yield 'Set.'
if status == 'fault':
continue
yield 'Go!'
started = True
break
5 changes: 2 additions & 3 deletions examples/improved_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ def footrace():
The footrace generator will start over if it is sent
a string 'fault'
"""
started = False
while not started:
while True:
status = yield 'On your marks.'
if status == 'fault':
continue
status = yield 'Set.'
if status == 'fault':
continue
yield 'Go!'
started = True
break