MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / run_client

Function run_client

example_code/item_076.py:246–267  ·  view source on GitHub ↗
(address)

Source from the content-addressed store, hash-verified

244
245print("Example 14")
246def run_client(address):
247 with socket.create_connection(address) as server_sock:
248 server = Connection(server_sock)
249
250 with new_game(server, 1, 5, 3) as session:
251 results = [outcome for outcome in session]
252
253 with new_game(server, 10, 15, 12) as session:
254 for outcome in session:
255 results.append(outcome)
256
257 with new_game(server, 1, 3, 2) as session:
258 it = iter(session)
259 while True:
260 try:
261 outcome = next(it)
262 except StopIteration:
263 break
264 else:
265 results.append(outcome)
266
267 return results
268
269
270print("Example 15")

Callers 1

mainFunction · 0.85

Calls 3

ConnectionClass · 0.85
new_gameFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected