From 2ddc278875f789de622262ee8ff5a1c3788f031c Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Wed, 2 Feb 2022 18:28:52 -0800 Subject: bpo-45975: Use walrus operator for some idlelib while loops (GH-31083) (cherry picked from commit 51a95be1d035a717ab29e98056b8831a98e61125) Co-authored-by: Nick Drozd --- Lib/idlelib/replace.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'Lib/idlelib/replace.py') diff --git a/Lib/idlelib/replace.py b/Lib/idlelib/replace.py index 2f9ca231a0..ac04ed94dd 100644 --- a/Lib/idlelib/replace.py +++ b/Lib/idlelib/replace.py @@ -158,11 +158,8 @@ class ReplaceDialog(SearchDialogBase): first = last = None # XXX ought to replace circular instead of top-to-bottom when wrapping text.undo_block_start() - while True: - res = self.engine.search_forward(text, prog, line, col, - wrap=False, ok=ok) - if not res: - break + while (res := self.engine.search_forward( + text, prog, line, col, wrap=False, ok=ok)): line, m = res chars = text.get("%d.0" % line, "%d.0" % (line+1)) orig = m.group() -- cgit v1.2.1