From 50d13ba730368064b647af5e18dca524510ec9ed Mon Sep 17 00:00:00 2001 From: Jonathan Slenders Date: Sat, 9 Nov 2024 21:02:05 +0000 Subject: [PATCH] Use f-strings in examples where possible. --- examples/progress-bar/a-lot-of-parallel-tasks.py | 2 +- examples/prompts/asyncio-prompt.py | 2 +- examples/prompts/patch-stdout.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/progress-bar/a-lot-of-parallel-tasks.py b/examples/progress-bar/a-lot-of-parallel-tasks.py index a20982789..007bdb6ff 100755 --- a/examples/progress-bar/a-lot-of-parallel-tasks.py +++ b/examples/progress-bar/a-lot-of-parallel-tasks.py @@ -39,7 +39,7 @@ def stop_task(label, total, sleep_time): threads = [] for i in range(160): - label = "Task %i" % i + label = f"Task {i}" total = random.randrange(50, 200) sleep_time = random.randrange(5, 20) / 100.0 diff --git a/examples/prompts/asyncio-prompt.py b/examples/prompts/asyncio-prompt.py index 32a1481d9..bd97fb3a9 100755 --- a/examples/prompts/asyncio-prompt.py +++ b/examples/prompts/asyncio-prompt.py @@ -26,7 +26,7 @@ async def print_counter(): try: i = 0 while True: - print("Counter: %i" % i) + print(f"Counter: {i}") i += 1 await asyncio.sleep(3) except asyncio.CancelledError: diff --git a/examples/prompts/patch-stdout.py b/examples/prompts/patch-stdout.py index 3a89f3650..7a283b601 100755 --- a/examples/prompts/patch-stdout.py +++ b/examples/prompts/patch-stdout.py @@ -21,7 +21,7 @@ def thread(): i = 0 while running: i += 1 - print("i=%i" % i) + print(f"i={i}") time.sleep(1) t = threading.Thread(target=thread)