From 8d925a9393a4b80778bcad5c265cbbcd787092ab Mon Sep 17 00:00:00 2001 From: James Prior Date: Mon, 20 Mar 2017 18:18:14 -0400 Subject: [PATCH] examples/*.py: Use break instead of "started" loop flag. --- examples/generator_delegation_correct.py | 5 ++--- examples/generator_delegation_return.py | 5 ++--- examples/generator_delegation_wrong.py | 5 ++--- examples/improved_generator.py | 5 ++--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/examples/generator_delegation_correct.py b/examples/generator_delegation_correct.py index 2e0c071..5d58bff 100644 --- a/examples/generator_delegation_correct.py +++ b/examples/generator_delegation_correct.py @@ -23,8 +23,7 @@ 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 @@ -32,4 +31,4 @@ def footrace(): if status == 'fault': continue yield 'Go!' - started = True + break diff --git a/examples/generator_delegation_return.py b/examples/generator_delegation_return.py index da21277..f7cb379 100644 --- a/examples/generator_delegation_return.py +++ b/examples/generator_delegation_return.py @@ -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 @@ -39,6 +38,6 @@ def footrace(): faults = faults + 1 continue yield 'Go!' - started = True + break return faults diff --git a/examples/generator_delegation_wrong.py b/examples/generator_delegation_wrong.py index 04b27c7..84f00c8 100644 --- a/examples/generator_delegation_wrong.py +++ b/examples/generator_delegation_wrong.py @@ -23,8 +23,7 @@ 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 @@ -32,4 +31,4 @@ def footrace(): if status == 'fault': continue yield 'Go!' - started = True + break diff --git a/examples/improved_generator.py b/examples/improved_generator.py index 7b3af21..f4c42d3 100644 --- a/examples/improved_generator.py +++ b/examples/improved_generator.py @@ -20,8 +20,7 @@ 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 @@ -29,4 +28,4 @@ def footrace(): if status == 'fault': continue yield 'Go!' - started = True + break