are final newlines appended if output lacks it?
John Machin
sjmachin at lexicon.net
Sat May 3 22:21:23 EDT 2003
More information about the Python-list mailing list
Sat May 3 22:21:23 EDT 2003
- Previous message (by thread): are final newlines appended if output lacks it?
- Next message (by thread): are final newlines appended if output lacks it?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, 04 May 2003 02:01:48 GMT, sjmachin at lexicon.net (John Machin) wrote: >On Sun, 04 May 2003 08:53:39 +0800, Dan Jacobson ><jidanni at dman.ddts.net> wrote: > >>Doing help() print explains how the blank got in here, >>$ python -c "print 'wow',;print 'pow',"|od -c >>0000000 w o w p o w \n >>0000010 >>But not the newline. Why? >>-- >>http://jidanni.org/ Taiwan(04)25854780 > >Doing help() print also explains how the newline got in there: >""" > A "\n" character is written at the end, unless the print statement >ends > with a comma. This is the only action if the statement contains just >the > keyword print. >""" derrrrr ..... my brain was in neutral. Dan's question/problem is quite valid, not explained by the documentation, and I have been able to reproduce it on Windows 2000 with Python 2.2.2. Doing this give the same effect as what Dan got, except that of course with Windows the offending extra is '\r\n' instead of just '\n': python -c "print 'wow',;print 'pow'," >powwow.txt Doing this: python -c "import sys;sys.stdout.write('abc');sys.stdout.write('xyz')" >abcxyz.txt produces no newline. Looks like there's an undocumented "feature" of the Python's print statement, nothing to do with the C stdio library or the OS.
- Previous message (by thread): are final newlines appended if output lacks it?
- Next message (by thread): are final newlines appended if output lacks it?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list