from contextlib import contextmanager
@contextmanager
def func():
print("With statement has started")
yield # the block after with is executed
print("With statement ends now")
with func():
print("Whatever has to be done will be done!")