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

Function close_open_files

example_code/item_070.py:40–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38os.chdir(TEST_DIR.name)
39
40def close_open_files():
41 everything = gc.get_objects()
42 for obj in everything:
43 if isinstance(obj, io.IOBase):
44 obj.close()
45
46atexit.register(close_open_files)
47### End book environment setup

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected