Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this code mean: "print >> sys.stderr"

Tags:

python

syntax

print >> sys.stderr, "Error in atexit._run_exitfuncs:" 

Why print '>>' in front of sys.stderr?

Thanks.

like image 814
zjm1126 Avatar asked Jan 01 '10 01:01

zjm1126


People also ask

What does Sys stderr do in python?

Python stderr is known as a standard error stream. It is similar to stdout because it also directly prints to the console but the main difference is that it only prints error messages. After writing the above code (python print to stderr), you can observe that it print debug message using sys. stderr.

What is file SYS stderr python?

The default value of file is sys. stdout . Both stdout and stderr are just used to display text from your program in the terminal, by default. See for example Wikipedia for more details on standard streams.

How do I print to stderr?

Use the fprintf Function to Print to stderr in C standard input ( stdin ) - used for reading input. standard output ( stdout ) - used for writing output. standard error stream ( stderr ) - used to log error or debug messages during run-time.


1 Answers

This syntax means writes to a file object (sys.stderr in this case) instead of standard output. [Link]

In Python 3.0, print becomes a function instead of a statement: [Link]

print("Error in atexit._run_exitfuncs:", file=sys.stderr) 
like image 176
iamamac Avatar answered Sep 24 '22 17:09

iamamac