(self, predecessor)
Makes the given element the immediate predecessor of this one.

        The two elements will have the same parent, and the given element
        will be immediately before this one.
Makes the given element the immediate predecessor of this one.
Makes the given element the immediate predecessor of this one .
def insert_before(self, predecessor):
        """Makes the given element the immediate predecessor of this one.

        The two elements will have the same parent, and the given element
        will be immediately before this one.
        """
        if self is predecessor:
            raise ValueError("Can't insert an element before itself.")
        parent = self.parent
        if parent is None:
            raise ValueError(
                "Element has no parent, so 'before' has no meaning.")
        # Extract first so that the index won't be screwed up if they
        # are siblings.
        if isinstance(predecessor, PageElement):
            predecessor.extract()
        index = parent.index(self)
        parent.insert(index, predecessor)
def insert_before ( self , predecessor ) : if self is predecessor : raise ValueError ( "Can't insert an element before itself." ) parent = self . parent if parent is None : raise ValueError ( "Element has no parent, so 'before' has no meaning." ) # Extract first so that the index won't be screwed up if they # are siblings. if isinstance ( predecessor , PageElement ) : predecessor . extract ( ) index = parent . index ( self ) parent . insert ( index , predecessor )