Message378332
For the original problem, how about this?
def process_file(file_or_path):
if isinstance(file_or_path, str):
# If string, open file
cm = open
else:
# Caller is responsible for closing file
cm = nullcontext
with cm(file_or_path) as file:
# Perform processing on the file |
|
Date |
User |
Action |
Args |
2020-10-09 15:02:32 | iritkatriel | set | recipients:
+ iritkatriel, ncoghlan, vstinner, eric.smith, serhiy.storchaka, miss-islington |
2020-10-09 15:02:32 | iritkatriel | set | messageid: <1602255752.62.0.889214959109.issue34067@roundup.psfhosted.org> |
2020-10-09 15:02:32 | iritkatriel | link | issue34067 messages |
2020-10-09 15:02:32 | iritkatriel | create | |
|