Jul-22-2018, 08:08 PM
So a Context Manager with statement class must have __enter__() and __exit__() .
For example file objects with will automatically close the file.
#2) How do you overwrite it (as in file objects for example?)
Thanks
For example file objects with will automatically close the file.
with open("/Users/user/tmp/workData.txt", "w") as work_data: for value in h: str_value = str(value) work_data.write(str_value) work_data.write("\n")#1) How does one know if a class object supports the Context Manager. What should I be looking for in the docs?
#2) How do you overwrite it (as in file objects for example?)
Thanks