How to print to stderr in Python?
How do I print to stderr in Python? Question: There are several ways to write to stderr: print >> sys.stderr, "spam" # Python 2 only. sys.stderr.write("spamn") os.write(2, b"spamn") from __future__ import print_function print("spam", file=sys.stderr) What are the differences between these methods? Which method should be preferred? Asked By: wim || Source Answers: import sys sys.stderr.write() …