Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65677

Re: What is the most pythonic way to build up large strings?

From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: What is the most pythonic way to build up large strings?
Date 2014-02-08 13:34 +0000
References <fd73769f-b291-4543-82a3-872451f67342@googlegroups.com> <e41758ef-bc50-48b9-bd39-3899c0c3e643@googlegroups.com> <be44deb7-547b-410d-a48a-dc3c7717b007@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.6539.1391866505.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 08/02/2014 10:11, cstrutton11@gmail.com wrote:
> On Saturday, February 8, 2014 3:13:54 AM UTC-5, Asaf Las wrote:
>
>>
>> note, due to strings are immutable - for every line in sum operation
>>
>> above you produce new object and throw out older one. you can write
>>
>> one string spanned at multiple lines in very clear form.
>>
>> /Asaf
>
> I think I going to rewrite this to build up a list of strings and then run a join on them at the end.  Each section can be conditionally built up with variable insertions as required.  This should be more efficient and will scale nicely as required.
>

An alternative is to use io.Stringio which is available in Python 2.7 
and 3.x.

Also would you please read and action this 
https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the 
double line spacing above, thanks.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

What is the most pythonic way to build up large strings? cstrutton11@gmail.com - 2014-02-07 23:41 -0800
  Re: What is the most pythonic way to build up large strings? Asaf Las <roegltd@gmail.com> - 2014-02-08 00:13 -0800
    Re: What is the most pythonic way to build up large strings? cstrutton11@gmail.com - 2014-02-08 01:56 -0800
      Re: What is the most pythonic way to build up large strings? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-08 11:06 +0000
      Re: What is the most pythonic way to build up large strings? Asaf Las <roegltd@gmail.com> - 2014-02-08 03:28 -0800
        Re: What is the most pythonic way to build up large strings? Rustom Mody <rustompmody@gmail.com> - 2014-02-08 04:33 -0800
    Re: What is the most pythonic way to build up large strings? cstrutton11@gmail.com - 2014-02-08 02:11 -0800
      Re: What is the most pythonic way to build up large strings? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-08 13:34 +0000
  Re: What is the most pythonic way to build up large strings? Rustom Mody <rustompmody@gmail.com> - 2014-02-08 00:35 -0800
    Re: What is the most pythonic way to build up large strings? cstrutton11@gmail.com - 2014-02-08 01:51 -0800
      Re: What is the most pythonic way to build up large strings? Dave Angel <davea@davea.name> - 2014-02-08 09:25 -0500
    Re: What is the most pythonic way to build up large strings? Roy Smith <roy@panix.com> - 2014-02-08 07:15 -0500
    Re: What is the most pythonic way to build up large strings? "Eric S. Johansson" <esj@harvee.org> - 2014-02-08 09:42 -0500
  Re: What is the most pythonic way to build up large strings? Peter Otten <__peter__@web.de> - 2014-02-08 09:51 +0100

csiph-web