Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; 'args': 0.04; 'great.': 0.07; 'trailing': 0.07; 'args,': 0.09; 'list...': 0.09; 'mutable': 0.09; 'cc:addr:python-list': 0.10; ':-)': 0.13; 'fine.': 0.16; 'oct': 0.16; 'structures,': 0.16; 'wrote:': 0.17; '(in': 0.18; 'assuming': 0.22; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'case,': 0.29; 'probably': 0.29; 'fri,': 0.30; 'not.': 0.32; 'received:gov': 0.33; 'problem': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'problem,': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'charset:us-ascii': 0.36; 'enough': 0.36; 'does': 0.37; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'sure': 0.38; 'performance': 0.39; 'space': 0.39; 'header:Received:5': 0.40; 'easy': 0.60; 'content-disposition:inline': 0.60; 'fun': 0.64; '26,': 0.65; 'enjoy': 0.67; 'subject:better': 0.84; 'sporting': 0.91; 'angel': 0.93 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent :x-gm-message-state; bh=fCtDLg+OtDasCT71lz+gXfaQJ3HZqeb7ENx50dU2uOU=; b=W7fZnqw1Yx8JJG/AfKLqUBejTYN5RfibLIq+3z+I3pJZHdSCOTuL9yntU6Nf1hJGHu 3kFxGokWM1PTNzhEcLFEaabz26M+5G9wgb9O4mPD8HHer8v/aNHAP5lLSde2s/xoPqYs w0SewmM4og5qOJvZLkrLKe0cdpfZAo+nxT+HT5xLnVEOUY9k6AyyWOBGAVx8RzKnyuuv eOtJFdXDbZTPDiUTP9GXNo0Jj+RzK+KfERknAIlSZw0loCr8Zd/9FupnYEquNlI9WbC7 6chkieBDA9DkavBFc+OfIwetHTe9o9eyQ/DW05Jc1rqOBYbaboFx6VSyHtKJ+pMEzUoK UyqA== Date: Fri, 26 Oct 2012 16:42:17 -0500 From: Tycho Andersen To: Dave Angel Subject: Re: better way for ' '.join(args) + '\n'? References: <20121026212602.GE25893@ccapuser-ubuntu.WICOURTS.GOV> <508B0272.2020003@davea.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <508B0272.2020003@davea.name> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQmOl7YRY3sc8Ag3RU2LGK9xhbU3/0EYhJKKSQM4OUVnXfx1NMPDlK5mLRBNe68+DasQKFyP Cc: python-list@python.org, Ulrich Eckhardt 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351287734 news.xs4all.nl 6917 [2001:888:2000:d::a6]:37554 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32236 On Fri, Oct 26, 2012 at 05:36:50PM -0400, Dave Angel wrote: > On 10/26/2012 05:26 PM, Tycho Andersen wrote: > > Assuming it's the length of the list that's the problem, not the > > length of the strings in the list... > > > > args = ['foo', 'bar', 'baz'] > > args[-1] = args[-1] + '\n' > > line = ' '.join(args) > > > > \t > > Main problem with that is the trailing space before the newline. If > that's not a problem, then fine. What trailing space before the newline? The other solutions have it, the above does not. However, the above does mutate args, which isn't all that great. Alas, if you want the performance of mutable structures, you're probably going to have to mutate something. (In any case, it's easy enough to change it back, though ugly.) > Not sure why we try so hard to optimize something that's going to take > negligible time. The same reason some people enjoy sporting events: it's fun :-) \t