line wrapping problem
Kent Johnson
kent at kentsjohnson.com
Thu Feb 9 11:49:44 EST 2006
S Borg wrote:
> Hello,
>
> I am parsing text from one document to another. I have a scheme
> similar to:
>
> for x in myfoobar:
> print >> mytextfile, "%s " % mydictionary[x], #all on same line
> print >> mytextfile, '\n' #new line
>
>
> I am getting line breaks before my explicit line break. Am I
> unwittingly copying '\n' characters from the original file?
Where does mydictionary[x] come from? If it is from reading lines from a
file it may contain trailing newlines.
Also
print >> mytextfile, '\n'
will print two newlines, one explicit and one implicit in the print.
Kent
More information about the Python-list
mailing list