Open a List of Files

Tim Chase python.list at tim.thechases.com
Wed Jan 9 09:40:33 EST 2008


> You don't need "for fn in open_files.keys():", you can just use "for fn in
> open_files:", but simpler than that is to just use the dictionary values:
> 
> for fn in open_files.values():
>     fn.close()

This can also work for standard variable names:

   for f in (messages, deliveries, actions, parts,
       recipients, viruses, esp_scores):
     f.close()

-tkc





More information about the Python-list mailing list