class Prompt:
def __init__(self, pstr = "enter value #> "):
self.pstr = pstr
def __enter__(self):
return input(self.pstr)
def __exit__(self, exc_type, exc_value, traceback):
return None
foo = None
with Prompt("> ") as inp:
def foo_impl():
print(f"foo_impl: {inp}")
foo = foo_impl
foo()
foo_impl()