From 4cdc07ef84bdad5867fe1079b4e425aa4a3771af Mon Sep 17 00:00:00 2001 From: Romuald Brunet Date: Tue, 3 Nov 2026 15:46:39 +0100 Subject: [PATCH] Docs: use f-strings in asyncio-protocol.rst (GH-161248) Switch to f-strings in asyncio-protocol.rst examples (cherry picked from commit ef985af0f201c390d903abde231c25bb9d50ec27) Co-authored-by: Romuald Brunet --- Doc/library/asyncio-protocol.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Doc/library/asyncio-protocol.rst b/Doc/library/asyncio-protocol.rst index 58f77feb3119841..4670d493ff71c64 100644 --- a/Doc/library/asyncio-protocol.rst +++ b/Doc/library/asyncio-protocol.rst @@ -734,14 +734,14 @@ received data, and close the connection:: class EchoServerProtocol(asyncio.Protocol): def connection_made(self, transport): peername = transport.get_extra_info('peername') - print('Connection from {}'.format(peername)) + print(f'Connection from {peername}') self.transport = transport def data_received(self, data): message = data.decode() - print('Data received: {!r}'.format(message)) + print(f'Data received: {message!r}') - print('Send: {!r}'.format(message)) + print(f'Send: {message!r}') self.transport.write(data) print('Close the client socket') @@ -787,10 +787,10 @@ data, and waits until the connection is closed:: def connection_made(self, transport): transport.write(self.message.encode()) - print('Data sent: {!r}'.format(self.message)) + print(f'Data sent: {message!r}') def data_received(self, data): - print('Data received: {!r}'.format(data.decode())) + print(f'Data received: {data.decode()!r}') def connection_lost(self, exc): print('The server closed the connection') @@ -843,8 +843,8 @@ method, sends back received data:: def datagram_received(self, data, addr): message = data.decode() - print('Received %r from %s' % (message, addr)) - print('Send %r to %s' % (message, addr)) + print(f'Received {message!r} from {addr}') + print(f'Send {message!r} to {addr}') self.transport.sendto(data, addr)