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: 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 Subject: Re: What is the most pythonic way to build up large strings? Date: Sat, 08 Feb 2014 13:34:38 +0000 References: 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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