[Tutor] Newbie Trouble Processing SRT Strings In Text File

Alan Gauld alan.gauld at btinternet.com
Fri Oct 31 18:13:54 CET 2014


On 31/10/14 11:07, Matt Varner wrote:

> # Import sys to get at stdout (standard output) - "print" results will
> be written to file
> import sys

This is a bad idea.
Instead, write your strings directly to o

o.write(s)

Print adds newlines automatically(unless you explicitly suppress them).
But printing to a file is messy compared to writing directly to the file.

(And also means you cant print debug messages while developing
your code!)

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list