I would like to know if there is a way to get the code of the following lambda functions:
a = {"test": lambda x: x + 123, "test2": lambda x: x + 89}
Is there a way to like
print(getsource(a["test"])
That returns :
lambda x: x + 123
I'm already aware of inspect and dill getsource functions but the following code:
import inspect
import dill
if __name__ == "__main__":
a = {"test": lambda x: x + 123, "test2": lambda x: x + 89}
print(inspect.getsource(a["test"]))
print(dill.source.getsource(a["test"]))
Returns:
a = {"test": lambda x: x + 123, "test2": lambda x: x + 89}
a = {"test": lambda x: x + 123, "test2": lambda x: x + 89}