Skip to content

Commit a2447f3

Browse files
romualdmiss-islington
authored andcommitted
Docs: use f-strings in asyncio-protocol.rst (GH-161248)
Switch to f-strings in asyncio-protocol.rst examples (cherry picked from commit ef985af) Co-authored-by: Romuald Brunet <romuald@chivil.com>
1 parent d9606d9 commit a2447f3

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎Doc/library/asyncio-protocol.rst‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -734,14 +734,14 @@ received data, and close the connection::
734734
class EchoServerProtocol(asyncio.Protocol):
735735
def connection_made(self, transport):
736736
peername = transport.get_extra_info('peername')
737-
print('Connection from {}'.format(peername))
737+
print(f'Connection from {peername}')
738738
self.transport = transport
739739

740740
def data_received(self, data):
741741
message = data.decode()
742-
print('Data received: {!r}'.format(message))
742+
print(f'Data received: {message!r}')
743743

744-
print('Send: {!r}'.format(message))
744+
print(f'Send: {message!r}')
745745
self.transport.write(data)
746746

747747
print('Close the client socket')
@@ -787,10 +787,10 @@ data, and waits until the connection is closed::
787787

788788
def connection_made(self, transport):
789789
transport.write(self.message.encode())
790-
print('Data sent: {!r}'.format(self.message))
790+
print(f'Data sent: {message!r}')
791791

792792
def data_received(self, data):
793-
print('Data received: {!r}'.format(data.decode()))
793+
print(f'Data received: {data.decode()!r}')
794794

795795
def connection_lost(self, exc):
796796
print('The server closed the connection')
@@ -843,8 +843,8 @@ method, sends back received data::
843843

844844
def datagram_received(self, data, addr):
845845
message = data.decode()
846-
print('Received %r from %s' % (message, addr))
847-
print('Send %r to %s' % (message, addr))
846+
print(f'Received {message!r} from {addr}')
847+
print(f'Send {message!r} to {addr}')
848848
self.transport.sendto(data, addr)
849849

850850

0 commit comments

Comments
 (0)