[Python-Dev] PEP 259: Omit printing newline after newline

M.-A. Lemburg mal@lemburg.com
Mon, 11 Jun 2001 22:55:13 +0200

Guido van Rossum wrote:
> Please comment on the following.  This came up a while ago in
> python-dev and I decided to follow through.  I'm making this a PEP
> because of the risk of breaking code (which everybody on Python-dev
> seemed to think was acceptable).
> --Guido van Rossum (home page: http://www.python.org/~guido/)
> PEP: 259
> Title: Omit printing newline after newline
> ...
> Scope
>     This only affects printing of 8-bit strings.  It doesn't affect
>     Unicode, although that could be considered a bug in the Unicode
>     implementation.  It doesn't affect other objects whose string
>     representation happens to end in a newline character.

I guess I should fix the Unicode stuff ;-)
> Risks
>     This change breaks some existing code.  For example:
>         print "Subject: PEP 259\n"
>         print message_body
>     In current Python, this produces a blank line separating the
>     subject from the message body; with the proposed change, the body
>     begins immediately below the subject.  This is not very robust
>     code anyway; it is better written as
>         print "Subject: PEP 259"
>         print
>         print message_body
>     In the test suite, only test_StringIO (which explicitly tests for
>     this feature) breaks.

Hmm, I think the above is a very typical idiom for RFC822
style content and used in CGI scripts a lot. I'm not sure whether
this change is worth getting the CGI crowd upset...

Wouldn't it make sense to only use this technique in inter-
active mode ?
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
Company & Consulting:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/