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

Function lookup_explicit

example_code/item_088.py:179–189  ·  view source on GitHub ↗
(my_key)

Source from the content-addressed store, hash-verified

177
178print("Example 14")
179def lookup_explicit(my_key):
180 try:
181 return my_dict[my_key]
182 except KeyError as e: # Changed
183 try:
184 result = contact_server(my_key)
185 except ServerMissingKeyError:
186 raise MissingError from e # Changed
187 else:
188 my_dict[my_key] = result
189 return result
190
191
192print("Example 15")

Callers 1

item_088.pyFile · 0.85

Calls 1

contact_serverFunction · 0.85

Tested by

no test coverage detected