I am running in a loop an astronomical script written by another person. This is a minimal version of my loop:
from astro_script_file import some_astro_class
for file_name in ['file_1.txt', 'file_2.txt', 'file_n.txt']:
some_astro_class.function_1(file_name)
When executing the above function_1
makes calculations based on the input txt-file and prints an output to the screen of the kind number of populated galaxies: some-number
. The number of galaxies is declining with each iteration of my loop and I want to break the loop when the number reaches 0. For that I need to somehow read in the print statement or load it into a variable. I don't want to alter the astronomical script itself that I am provided with, instead I want to tinker only outside of it when I am executing the script.
Is this possible? Is there some way to load print statements when they get executed?