I've read some Python docs, but I can't find where the print_exc function prints. So I searched some stack overflow, it says "print_exc()
prints formatted exception to stdout". Link
I've been so confused.. In my opinion, that function should print to stderr because it's ERROR!.. What is right?
It prints to stderr
, as can be seen from the following test:
$ cat test.py
try:
raise IOError()
except:
import traceback
traceback.print_exc()
$ python test.py
Traceback (most recent call last):
File "test.py", line 2, in <module>
raise IOError()
IOError
$ python test.py > /dev/null
Traceback (most recent call last):
File "test.py", line 2, in <module>
raise IOError()
IOError
$ python test.py 2> /dev/null
$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With