I have a question in python, if someone can please help Here is example, I have a contextmanager as below
from contextlib import contextmanager
@contextmanager
def main_func(name):
print("<%s>" % name)
yield
print("</%s>" % name)
# Retreive the list of function here : tag_func1 and tag_func2 then run the one I need to run
then use it like below
with main_func("h1"):
def tag_func1():
print("foo1")
def tag_func2():
print("foo2")
I would like to know is possible to retreive the list of function defined in the with statement here tag_func1 and tag_func1 and run them dynamically in the code.
I need to perform those actions into the function main_func implementing the contextmanager
Many thanks for you help,