The UserString module

(New in 2.0) This module contains two classes, UserString and MutableString. The former is a wrapper for the standard string type which can be subclassed, the latter is a variation that allows you to modify the string in place.

Note that MutableString is not very efficient. Most operations are implemented using slicing and string concatenation. If performance is important, use lists of string fragments, or the array module.

Example: Using the UserString module
# File:

import UserString

class MyString(UserString.MutableString):

    def append(self, s): = + s

    def insert(self, index, s): =[index:] + s +[index:]

    def remove(self, s): =, "")

file = open("samples/book.txt")
text =

book = MyString(text)

for bird in ["gannet", "robin", "nuthatch"]:

print book

C: The one without the !
P: The one without the -!!! They've ALL got the !! It's a
Standard British Bird, the , it's in all the books!!!

A Django site. rendered by a django application. hosted by webfaction.