HHousen / lecture2notes

File opened without the with statement PTC-W0010
Anti-pattern
Critical
3 years ago4 years old
Use the with statement to open a file
29
30def write_to_file(results, save_file):
31    """Write everything stored in `results` to file at path `save_file`. Used to write results from `all_in_folder()` to `save_file`."""
32    file_results = open(save_file, "a+")33    logger.info("Writing results to file " + str(save_file))
34    for item in tqdm(
35        results, total=len(results), desc="> OCR: Writing To File Progress"