Isn't what he's describing very similar to the "with" statement in Python? You can define a context manager to use with "with" that has methods that get executed on the entry and exit of the "with" block, e.g., to open/close a file or acquire/release a lock.