My Cut at PEP 259
Chris Gonnerman
chris.gonnerman at newcenturycomputers.net
Thu Jun 14 00:33:20 EDT 2001
I have to agree that .softspace is not my favorite thing. Here's
how I see it:
Right now, given the following code (numbered for later reference):
1) print "Goodbye", "Gruel",
print "World"
you get this (with underscores in place of spaces)
2) Goodbye_Gruel_World
Now try this:
3) print "Goodbye", "Gruel",
sys.stdout.write("\n")
print "World"
and you get this mess:
4) Goodbye_Gruel
_World
This generates a couple of messages from newbies each month
regarding print and raw_input().
Instead, let's imagine throwing out .softspace entirely and
assume a print statement which replaces every comma (except
after the >>>fileobj construct, if present) with a space and
adds a newline at the end except when the last token is a comma.
Figure 3's code gives this result:
5) Goodbye_Gruel_
World
This, IMHO, is less surprising, and the results of Figure 1's
code is still Figure 2.
Most expert Pythonians, aware of the behavior in Figure 4,
avoid code like Figure 3 automatically, so this change should
result in very little code breakage. Newbies will probably
ask on the list how to get rid of the extra space when they
do this:
6) print "A prompt:",
resp = raw_input()
but I doubt this would be more common than the current question
and perhaps easier to explain.
I'm still in favor of print mapping to a __print__() function
of some sort, but this proposal would work either way.
More information about the Python-list
mailing list