some objects offer context management which provides more convenient way to write try finally blockswith open test txt as for line in print line after the with block the file object is guaranteed to be closed properlyno matter what exceptions occurred within the block class method __enter__(selfwill be executed at the beginning and class method __exit__at the end of the context member of the helmholtz association slide