Python has several things that fulfill similar purposes:
- One common way to build large strings from pieces is to grow a list of strings and join it when you are done. This is a frequently-used Python idiom.
- To build strings incorporating data with formatting, you would do the formatting separately.
- For insertion and deletion at a character level, you would keep a list of length-one strings. (To make this from a string, you'd call
list(your_string)
. You could also use a UserString.MutableString
for this.
(c)StringIO.StringIO
is useful for things that would otherwise take a file, but less so for general string building.