https://github.com/python/cpython/commit/ef985af0f201c390d903abde231c25bb9d50ec27
commit: ef985af0f201c390d903abde231c25bb9d50ec27
branch: main
author: Romuald Brunet <[email protected]>
committer: nedbat <[email protected]>
date: 2026-11-03T14:46:39Z
summary:

Docs: use f-strings in asyncio-protocol.rst (#161248)

Switch to f-strings in asyncio-protocol.rst examples

files:
M Doc/library/asyncio-protocol.rst

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)
 
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to