# Note: this first one does not work in Python 3 print >> sys.stderr, "spam" sys.stderr.write("spam ") os.write(2, b"spam ") from __future__ import print_function print("spam", file=sys.stderr)