Python strings question (vertical stack)

John Machin sjmachin at lexicon.net
Tue Nov 20 17:15:31 EST 2007


James Matthews top-posted:
> I would say to split it by the newline!

Split what by which newline? The OP appeared to be wanting some kind of 
UNsplit ...

>
> On Nov 20, 2007 10:59 PM, John Machin <sjmachin at lexicon.net 
> <mailto:sjmachin at lexicon.net>> wrote:
>
>     On Nov 21, 7:15 am, Farshid Lashkari <n... at spam.com
>     <mailto:n... at spam.com>> wrote:
>     > J. Clifford Dyer wrote:
>     > > I think you mean '\n'.join([string1,string2,string3])
>     >
>     > > You actually do want the \ to do its thing in this case.
>     >
>     > Yeah, my brain must still be asleep. Thanks for waking it up :)
>
>     You're not alone :-)
>
Early indications of a pandemic??

>
>     >>> a = """
>     ... x
>     ... y
>     ... z
>     ... """
>     >>> a
>     '\nx\ny\nz\n'
>     >>> '\n'.join(['x', 'y', 'z'])
>     'x\ny\nz'
>     >>>
>
>




More information about the Python-list mailing list