Re: better way for ' '.join(args) + '\n'?

2012-11-03 Thread Ramchandra Apte
On Saturday, 27 October 2012 03:12:31 UTC+5:30, Tycho Andersen wrote: 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...

RE: better way for ' '.join(args) + '\n'?

2012-10-29 Thread Prasad, Ramit
Thomas Rachel wrote: Am 26.10.2012 09:49 schrieb Ulrich Eckhardt: Hi! General advise when assembling strings is to not concatenate them repeatedly but instead use string's join() function, because it avoids repeated reallocations and is at least as expressive as any alternative.

Re: better way for ' '.join(args) + '\n'?

2012-10-27 Thread Thomas Rachel
Am 26.10.2012 09:49 schrieb Ulrich Eckhardt: Hi! General advise when assembling strings is to not concatenate them repeatedly but instead use string's join() function, because it avoids repeated reallocations and is at least as expressive as any alternative. What I have now is a case where I'm

better way for ' '.join(args) + '\n'?

2012-10-26 Thread Ulrich Eckhardt
Hi! General advise when assembling strings is to not concatenate them repeatedly but instead use string's join() function, because it avoids repeated reallocations and is at least as expressive as any alternative. What I have now is a case where I'm assembling lines of text for driving a

Re: better way for ' '.join(args) + '\n'?

2012-10-26 Thread Peter Otten
Ulrich Eckhardt wrote: Hi! General advise when assembling strings is to not concatenate them repeatedly but instead use string's join() function, because it avoids repeated reallocations and is at least as expressive as any alternative. What I have now is a case where I'm assembling

Re: better way for ' '.join(args) + '\n'?

2012-10-26 Thread Steven D'Aprano
On Fri, 26 Oct 2012 09:49:50 +0200, Ulrich Eckhardt wrote: Hi! General advise when assembling strings is to not concatenate them repeatedly but instead use string's join() function, because it avoids repeated reallocations and is at least as expressive as any alternative. What I have now

Re: better way for ' '.join(args) + '\n'?

2012-10-26 Thread Hubert Grünheidt
Hi Ulrich, is this acceptable? args = ['foo', 'bar', 'baz'] args.append('\n') line = ' '.join(args) Cheers, Hubert On 10/26/2012 09:49 AM, Ulrich Eckhardt wrote: Hi! General advise when assembling strings is to not concatenate them repeatedly but instead use string's

Re: better way for ' '.join(args) + '\n'?

2012-10-26 Thread Tycho Andersen
On Fri, Oct 26, 2012 at 09:49:50AM +0200, Ulrich Eckhardt wrote: Hi! General advise when assembling strings is to not concatenate them repeatedly but instead use string's join() function, because it avoids repeated reallocations and is at least as expressive as any alternative. What I

Re: better way for ' '.join(args) + '\n'?

2012-10-26 Thread Dave Angel
On 10/26/2012 05:26 PM, Tycho Andersen wrote: On Fri, Oct 26, 2012 at 09:49:50AM +0200, Ulrich Eckhardt wrote: Hi! General advise when assembling strings is to not concatenate them repeatedly but instead use string's join() function, because it avoids repeated reallocations and is at least

Re: better way for ' '.join(args) + '\n'?

2012-10-26 Thread Tycho Andersen
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)