On Sep 2, 1:49 pm, Terry Reedy <tjre...@udel.edu> wrote: > 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.
Thanks again, Terry. There is a lot to the language, I am finding out. I am a HW engineer, not really a programmer. Python seems a lot more sophisticated than MATLAB. I'm kinda thinking `write` is likely to be a little more "stable" than `print` (if that is the right characterization) when my eventual switch from 2.7 to 3.x happens. You think? -- http://mail.python.org/mailman/listinfo/python-list