December 7th, 2004, 06:18 AM
difference between the two
Is there any difference between print and sys.stderr.write
>>> print "Test"
December 7th, 2004, 08:14 AM
(I think you meant sys.stdout.write() though...)
- sends output to the stderr pipe in unix
- sends output to the stdout pipe in unix
In windows systems, these both go to the current interacive window.
The print function basically adds a newline character to your string and calls sys.stdout.write() - so its basically a wrapper for it (with the difference being the \n).
December 7th, 2004, 09:19 AM
Since print (by default) ultimately calls sys.stdout.write you can change where printing goes by re-assigning sys.stdout to some other object with file like features (e.g a write method).
Now with the newer Pythons of course there is the output modifier: