@@ -49,7 +49,7 @@ def wsproto_demo(host: str, port: int) -> None:
4949 """
5050
5151 # 0) Open TCP connection
52- print ("Connecting to {}:{}" . format ( host , port ) )
52+ print (f "Connecting to { host } :{ port } " )
5353 conn = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
5454 conn .connect ((host , port ))
5555
@@ -64,14 +64,14 @@ def wsproto_demo(host: str, port: int) -> None:
6464
6565 # 2) Send a message and display response
6666 message = "wsproto is great"
67- print ("Sending message: {}" . format ( message ) )
67+ print (f "Sending message: { message } " )
6868 net_send (ws .send (Message (data = message )), conn )
6969 net_recv (ws , conn )
7070 handle_events (ws )
7171
7272 # 3) Send ping and display pong
7373 payload = b"table tennis"
74- print ("Sending ping: {!r}" . format ( payload ) )
74+ print (f "Sending ping: { payload !r} " )
7575 net_send (ws .send (Ping (payload = payload )), conn )
7676 net_recv (ws , conn )
7777 handle_events (ws )
@@ -111,9 +111,9 @@ def handle_events(ws: WSConnection) -> None:
111111 if isinstance (event , AcceptConnection ):
112112 print ("WebSocket negotiation complete" )
113113 elif isinstance (event , TextMessage ):
114- print ("Received message: {}" . format ( event .data ) )
114+ print (f "Received message: { event .data } " )
115115 elif isinstance (event , Pong ):
116- print ("Received pong: {!r}" . format ( event . payload ) )
116+ print (f "Received pong: { event . payload !r} " )
117117 else :
118118 raise Exception ("Do not know how to handle event: " + str (event ))
119119
0 commit comments