You can redirect prints from terminal to the external text file.
Something like that:
import os
import sys
# Open a file
file = open("output.txt", "w")
# Get the file descriptor
fd = file.fileno()
# Duplicate the file descriptor to the standard output
os.dup2(fd, sys.stdout.fileno())
# Now any print statement will write to the file
print("This message will be written to the file")
# Close the file
file.close()
You can redirect prints from terminal to the external text file.
Something like that:
Perhaps it can be useful for debugging.