| Store | Cart

newbie question: getting rid of space in string :(

From: Martin Franklin <mfra...@gatwick.westerngeco.slb.com>
Fri, 12 Jul 2002 18:49:50 +0000
On Friday 12 Jul 2002 5:30 pm, Alex Martelli wrote:
> Martin Franklin wrote:>         ...>> > as a matter of taste I would use this:-> > wholeString=wholeString+"<%s><b>%s</b></%s>" %(color, a, color)> > but as I say this is a matter of taste!>> Building up a large string by + concatenation of many> small ones is Python's main performance trap.  If you> want to build things up, build them up in a list instead,> then at the end you can use sys.stdout.writelines to write> it out or ''.join to make the big string.



I agree. I guess I was giving the OP what I consider the simplest way 
(without introducing anything too 'new' to him (he did say he was a newbie) 

Best Regards
Martin

Recent Messages in this Thread
Joseph Youssef Jul 12, 2002 05:52 am
Mark McEahern Jul 12, 2002 04:14 pm
Gerhard Haering Jul 12, 2002 04:17 pm
Martin Franklin Jul 12, 2002 04:59 pm
Alex Martelli Jul 12, 2002 05:29 pm
Alex Martelli Jul 12, 2002 05:30 pm
Martin Franklin Jul 12, 2002 06:49 pm
Messages in this thread