# 3.5 `UserString` -- Class wrapper for string objects

This module defines a class that acts as a wrapper around string objects. It is a useful base class for your own string-like classes, which can inherit from them and override existing methods or add new ones. In this way one can add new behaviours to strings.

The `UserString` module defines the `UserString` class:

`UserString` ([sequence])
  Return a class instance that simulates a string or a Unicode string object. The instance's content is kept in a regular string or Unicode string object, which is accessible via the `data` attribute of `UserString` instances. The instance's contents are initially set to a copy of sequence. sequence can be either a regular Python string or Unicode string, an instance of `UserString` (or a subclass) or an arbitrary sequence which can be converted into a string.

In addition to supporting the methods and operations of string or Unicode objects (see section 2.1.5), `UserString` instances provide the following attribute:

`data`
  A real Python string or Unicode object used to store the content of the `UserString` class.

`MutableString` ([sequence])
  This class is derived from the `UserString` above and redefines strings to be mutable. Mutable strings can't be used as dictionary keys, because dictionaries require immutable objects as keys. The main intention of this class is to serve as an educational example for inheritance and necessity to remove (override) the `__hash__` method in order to trap attempts to use a mutable object as dictionary key, which would be otherwise very errorprone and hard to track down.