raymond.chui at nospam
Oct 27, 2008, 11:29 AM
Post #1 of 2
By default the print statement sends to stdout
I want to send to stderr
print "my meeage", file=sys.stderr
> SyntaxError: invalid syntax
print "my message", sys.stderr
But it still sent to stdout.
What is the syntax?
I wouldn't understand Python's manual
> print([object, ...][, sep=' '][, end='n'][, file=sys.stdout])¶
> Print object(s) to the stream file, separated by sep and followed by end. sep, end and file, if present, must be given as keyword arguments.
> All non-keyword arguments are converted to strings like str() does and written to the stream, separated by sep and followed by end. Both sep and end must be strings; they can also be None, which means to use the default values. If no object is given, print() will just write end.
> The file argument must be an object with a write(string) method; if it is not present or None, sys.stdout will be used.