newbie question: getting rid of space in string :(
Alex Martelli
aleax at aleax.it
Fri Jul 12 13:30:59 EDT 2002
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.
Alex
More information about the Python-list
mailing list