supressing '\n' at the end

Irmen de Jong irmen at -nospam-remove-this-xs4all.nl
Sat Nov 6 17:10:11 EST 2004


SunX wrote:
> Gurus;
> I need some help here.  How do you supress the newline char. at the
> end of a file.write(str(aString))?  I know you can add a newline by
> simply doing file.write(str(aString) + '\n'), but not
> file.write(str(aString) - '\n').

Where does the \n come from? I presume the 'aString' object contains
it. Then you can do:

file.write(aString[:-1])

(but only if aString always contains a '\n' at the end, ofcourse)

--Irmen



More information about the Python-list mailing list