string building
sturlamolden
sturlamolden at yahoo.no
Mon Apr 3 12:58:09 EDT 2006
John Salerno wrote:
> Out of curiosity, is there any kind of equivalent in Python to the
> StringBuilder class in C#?
You can just append each string to a list and call "".join(list) on the
list. Here is a mock-up StringBuilder class:
class StringBuilder:
def __init__(self): self.strlist = list()
def Append(self,str): self.strlist.append(str)
def ToString(self): return "".join(self.strlist)
Implementing the rest of the .NET StringBuilder class is left as an
exercise:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtextstringbuilderclasstopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtextstringbuildermemberstopic.asp
More information about the Python-list
mailing list