string building

Duncan Booth duncan.booth at invalid.invalid
Mon Apr 3 10:53:28 EDT 2006


John Salerno wrote:

> Out of curiosity, is there any kind of equivalent in Python to the 
> StringBuilder class in C#? 

Yes, usually you use StringIO/cStringIO for this. It works for those 
situations where you just want to append to a string as you build it.

The alternative is just to build up a list of strings and then concatenate 
them all when you are done (using str.join).

If you really need mutable strings you can use the array module.



More information about the Python-list mailing list