Separator in print statement
Bertram Scharpf
b.scharpf at tesionmail.de
Tue Oct 14 13:18:40 EDT 2003
Hi Peter,
thank you for your detailed answer.
Peter Hansen schrieb im Artikel <3F8C2522.8D1729DD at engcorp.com>:
> The general rule with "print" is that it works like it does, and
> if you don't like the way it works, you need to switch to something
> else.
Anyway. I mean ' ' when I say ' '.
> If you require that the output be generated by separate statements
> or subroutine calls, then you will have to do something fairly
> complicated: create an object which acts like a file object, and
> which can collect blobs of data as you output them, but hold
> them in memory, writing them all out together after you send
> it the terminating sequence (\n in this case).
A nice idea; maybe I will have a closer look at it.
> A simpler option is just to collect up the bits of output that
> you need in a list, then use the string join() method to generate
> the output:
>
> outList = []
> outList.extend(['abc', 'def'])
> outList.append('ghi')
> print ', '.join(outList)
>
I think this list approach is what I really meant.
Thanks, also to Matt,
Bertram
--
Bertram Scharpf
Stuttgart, Deutschland/Germany
More information about the Python-list
mailing list