From f65907cb46f3d990d06b642961e0e4860b16174f Mon Sep 17 00:00:00 2001 From: Romuald Brunet Date: Tue, 3 Nov 2026 15:27:58 +0100 Subject: [PATCH] Docs: use f-strings in asyncio-protocol.rst Switch to f-strings in asyncio-protocol.rst examples --- 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 42c2d509d5a729..0c27ea53006077 100644 --- a/Doc/library/asyncio-protocol.rst +++ b/Doc/library/asyncio-protocol.rst @@ -737,14 +737,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') @@ -790,10 +790,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') @@ -846,8 +846,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)