I have a python script 'script1.py' which creates a dictionary 'out_dict' at the end of the execution. I'm calling 'script1.py' from another script 'script2.py'.
Is there any way to get only the final dictionary 'out_dict' (note : I have some print statements too in 'scirpt1.py') into a variable in 'script2.py'.
script1.py
......
......
some print statement
......
some print statement
......
out_dict = {...}
print(out_dict)
script2.py
import os
val = os.system("python3.6 script1.py")
print("MARKER")right beforeprint(out_dict)and then splitvalon this marker string and use only the second field of the split. Given that both scripts are in Python, wouldn't it be easier/better to just import one into the other and then directly pass dictionaries?