On Sep 2, 10:55 am, Chris Rebert <c...@rebertia.com> wrote: > On Sun, Sep 2, 2012 at 10:23 AM, gwhite <gwh...@ti.com> wrote: > > I can't figure out how to stop the "add a space at the beginning" > > behavior of the print function. > > >>>> print 1,;print 2, > > 1 2 > > > See the space in between the 1 and the 2 at the output print to the > > command console? > > > The help for print is: > > > "A space is written before each object is (converted and) written, > > unless the output system believes it is positioned at the beginning of > > a line." > > > So it is apparently doing what it is supposed to do. > > > Is there a way to stop this? > > If you were to use Python 3.x, yes. Otherwise, no. > > > Or is there a different function that > > will only print what you have in the formatted string? > > Use the .write() method of the sys.stdout file > object.http://docs.python.org/library/sys.html#sys.stdout > > Alternatively, you can stick with `print` and rework your code so that > it outputs an entire line at a time (thus, there'd only be 1 argument > passed to `print`, so its "spaces between arguments" feature wouldn't > come into play).
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. I was actually doing some simple tests of other things -- you know, newbie stuff to make sure I understood what the various ops were doing. I wasn't even thinking about `print` Then I got sidetracked with this item, which I thought was very odd, since it is "deciding for you" to stuff a space in. -- http://mail.python.org/mailman/listinfo/python-list