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?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'nicely': 0.07; 'string': 0.09; 'immutable': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rewrite': 0.09; 'subject:build': 0.09; 'python': 0.11; '2.7': 0.14; 'language.': 0.14; 'insertions': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'spacing': 0.16; 'subject:most': 0.16; 'throw': 0.16; 'prevent': 0.16; 'language': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'thanks.': 0.20; 'header:User-Agent:1': 0.23; 'url:moin': 0.24; '---': 0.24; 'required.': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'scale': 0.29; 'lines': 0.31; 'url:wiki': 0.31; 'run': 0.32; 'url:python': 0.33; 'older': 0.33; 'subject:the': 0.34; 'form.': 0.35; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'las': 0.37; 'list': 0.37; 'clear': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'above,': 0.60; 'free': 0.61; 'new': 0.61; 'viruses': 0.61; 'email addr:gmail.com': 0.63; 'protection': 0.63; 'our': 0.64; 'sum': 0.64; 'more': 0.64; 'due': 0.66; 'antivirus': 0.68; 'end.': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: What is the most pythonic way to build up large strings?
Date Sat, 08 Feb 2014 13:34:38 +0000
References <fd73769f-b291-4543-82a3-872451f67342@googlegroups.com> <e41758ef-bc50-48b9-bd39-3899c0c3e643@googlegroups.com> <be44deb7-547b-410d-a48a-dc3c7717b007@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-78-146-6-70.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.3.0
In-Reply-To <be44deb7-547b-410d-a48a-dc3c7717b007@googlegroups.com>
X-Antivirus avast! (VPS 140208-0, 08/02/2014), Outbound message
X-Antivirus-Status Clean
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6539.1391866505.18130.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391866505 news.xs4all.nl 2845 [2001:888:2000:d::a6]:56306
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65677

Show key headers only | 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