I want to redirect the print to a .txt file using python. I have a \'for\' loop, which will \'print\' the output for each of my .bam file while I want to redirect ALL these
If you are using Linux I suggest you to use the tee command. The implementation goes like this:
python python_file.py | tee any_file_name.txt
If you don't want to change anything in the code, I think this might be the best possible solution. You can also implement logger but you need do some changes in the code.