[Tutor] outputting long lines
Paul Tremblay
phthenry@earthlink.net
Sat Mar 8 15:12:02 2003
Thanks everyone.
It seems like Gregor's solution is the best. (See what he wrote in his
ps.) Would the solution in this email really save a lot of time in
comparison to Gregor's solution?
Paul
On Sat, Mar 08, 2003 at 12:11:39PM -0500, Erik Price wrote:
>
>
> On Saturday, March 8, 2003, at 01:21 AM, Paul Tremblay wrote:
>
> >Is there a tecnique for printing out long lines that span more than the
> >length of your script?
>
> One way to do it that doesn't sacrifice performance is to create a list
> of strings and then join them all together when they need to be treated
> as a single string.
>
> >>> text = [
> ... 'Here is a ',
> ... 'really long string ',
> ... 'that is broken up ',
> ... 'over multiple lines.'
> ... ]
> >>> text
> ['Here is a ', 'really long string ', 'that is broken up ', 'over
> multiple lines.']
> >>> output = ''.join(text)
> >>> output
> 'Here is a really long string that is broken up over multiple lines.'
> >>>
>
> Note that "output" is generated by calling the string method join() on
> an empty string, passing the list as the argument.
>
>
> Erik
>
>
>
>
> --
> Erik Price
>
> email: erikprice@mac.com
> jabber: erikprice@jabber.org
--
************************
*Paul Tremblay *
*phthenry@earthlink.net*
************************