https://github.com/python/cpython/commit/828861fb7e2a61ff7b8ee8c4f9557704439d47dc
commit: 828861fb7e2a61ff7b8ee8c4f9557704439d47dc
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: nedbat <[email protected]>
date: 2026-11-03T15:08:34Z
summary:

[3.15] Docs: use f-strings in asyncio-protocol.rst (GH-161248) (#161250)

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 <[email protected]>

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

diff --git a/Doc/library/asyncio-protocol.rst b/Doc/library/asyncio-protocol.rst
index 58f77feb311984..4670d493ff71c6 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)
 
 

_______________________________________________
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