On 9/2/2012 3:26 PM, gwhite wrote:
On the "rework" thing, yes, I suppose I could construct the line as a
single string prior to print. There would be things like `for`
loops and conditionals to do so. That isn't so unusual.
The usual idiom is to construct a list of pieces and then join with ''.
>>> print(''.join(['1', '2']))
12
Or map str to a list of objects.
>>> print(''.join(map(str, [1, 2])))
12
You can do either of these in 2.x.
If you use .write, include '\n' at the end of the list (when needed).
Print was designed as a quick and easy way to put lines of text on the
screen. Then people asked for a way to use with with other streams,
hence the >> hack. Then people wanted ways to control the separator and
terminator. As that point, Guido realized that it needed to be a
function, not a statement, with all the options requested.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list