I was hoping this would work:
class A:
def __enter__(self, code):
print code
def __exit__(..):
pass
and then:
with A():
f()
g()
would print:
f()
g()
Specifically, my intention is to take this code and create a function out of it. So I can do: with runInThreads()
or with runManyTimesTillSuccess()
,..