def __init__(self, contents):
        """Extend this list instance with given contents.

        Parameters
        ==========
        contents (string or list of CachedTextObject objects)
            contents to form the line.
        """
        ### initialize superclass
        super().__init__()

        ### instantiate a rect for the line (don't store
        ### it on self.rect, since it is the setter of
        ### a property inherited from List2D)
        self.line_rect = Rect((0, 0), (0, self.char_height))

        ### extend list with contents received, according
        ### to its type

        if isinstance(contents, str):
            self.extend_from_string(contents)

        elif isinstance(contents, list):
            self.extend(contents)

        ### if an unexpected type is received, raise an
        ### error explaining the problem

        else:

            raise TypeError("'contents' must be of type 'str'" " or 'list'")
Extend this list instance with given contents.

        Parameters
        ==========
        contents (string or list of CachedTextObject objects)
            contents to form the line.
        
nodezator/textman/editor/line.py