Hello !
I’ve a quick question to discuss the difference between python 2 and 3 and the way to treat the stdout by the gSystem.RedirectOutput.
Trying to be quick, I’m running macros for which part of the stdout is redirected to an output file through RedirectOutput method to produce display for a manual and the other part of the stdout is sent to a log file to collect the results of our tests.
I’m able to reproduce this with a very short macro provided along this post printPy3.py (247 Bytes)
To illustrate the difference seen, here is the same command run with python2 (and a ROOT 6.14.00 compiled accordingly) and a python 3 one (with a ROOT 6.14.00 compiled accordingly).
python2 printPy3.py -b > log.out && echo “test” && cat test.out && echo “log” && cat log.out
which gives this output :
test
Using print function.
TH1.Print Name = pouet, Entries= 0, Total sum= 0
Using sys.stdout function.
log
where everything print line from python is stored in test.out, along with the stdout from C++, which is what i expected. While this line
python3 printPy3.py -b > log.out && echo “test” && cat test.out && echo “log” && cat log.out
gives this result
test
TH1.Print Name = pouet, Entries= 0, Total sum= 0
log
Using print function.
Using sys.stdout function.
where everything is stored in the log file, but the stdout from C++ method.
If you have an idea of the possible difference between python 2 and 3 (or if this behaviour is due to the RedirectOutput method) I’d be glad to have advices.
Thanks in advance
cheers
JB
_ROOT Version:6.14.00
_Platform:Fedora26
_Compiler:gcc7.1