Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed3.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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'subject: + ': 0.07; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'strings.': 0.09; 'language.': 0.14; 'nose': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'such,': 0.16; 'write.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'this?': 0.23; 'header:User- Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'lines': 0.31; "skip:' 10": 0.31; 'subject:with': 0.35; 'but': 0.35; 'so,': 0.37; 'performance': 0.37; 'to:addr:python-list': 0.38; 'issue': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'numbers': 0.61; 'simply': 0.61; "you're": 0.61; 'our': 0.64; 'charset:windows-1252': 0.65; 'determine': 0.67; 'characters,': 0.84; 'received:2': 0.84; 'subject:Using': 0.84; 'fibonacci': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Using + with strings considered bad Date: Wed, 29 Apr 2015 10:08:41 +0100 References: <878udbxrpg.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-2-98-195-171.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: <878udbxrpg.fsf@Equus.decebal.nl> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430298608 news.xs4all.nl 2943 [2001:888:2000:d::a6]:59534 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3428 X-Received-Body-CRC: 3212055529 Xref: csiph.com comp.lang.python:89533 On 29/04/2015 09:29, Cecil Westerhof wrote: > Because I try to keep my lines (well) below 80 characters, I use the > following: > print('Calculating fibonacci and fibonacci_memoize once for ' + > str(large_fibonacci) + ' to determine speed increase') > > But I was told that using + with strings was bad practice. Is this > true? If so, what is the better way to do this? > It's not bad practice as such, it's simply that performance takes a nose dive if you're contatenating large numbers of strings. If performance is an issue the recommended way is to write. ' '.join(strings) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence