(self, expr, *args, **kwargs)
Internal dispatcher

        Tries the following concepts to print an expression:
            1. Let the object print itself if it knows how.
            2. Take the best fitting method defined in the printer.
            3. As fall-back use the emptyPrinter method for the printer.
Internal dispatcher
Internal dispatcher
def _print(self, expr, *args, **kwargs):
        """Internal dispatcher

        Tries the following concepts to print an expression:
            1. Let the object print itself if it knows how.
            2. Take the best fitting method defined in the printer.
            3. As fall-back use the emptyPrinter method for the printer.
        """
        self._print_level += 1
        try:
            # If the printer defines a name for a printing method
            # (Printer.printmethod) and the object knows for itself how it
            # should be printed, use that method.
            if (self.printmethod and hasattr(expr, self.printmethod)
                    and not isinstance(expr, BasicMeta)):
                return getattr(expr, self.printmethod)(self, *args, **kwargs)

            # See if the class of expr is known, or if one of its super
            # classes is known, and use that print function
            for cls in type(expr).__mro__:
                printmethod = '_print_' + cls.__name__
                if hasattr(self, printmethod):
                    return getattr(self, printmethod)(expr, *args, **kwargs)

            # Unknown object, fall back to the emptyPrinter.
            return self.emptyPrinter(expr)
        finally:
            self._print_level -= 1
def _print ( self , expr , * args , * * kwargs ) : self . _print_level += 1 try : # If the printer defines a name for a printing method # (Printer.printmethod) and the object knows for itself how it # should be printed, use that method. if ( self . printmethod and hasattr ( expr , self . printmethod ) and not isinstance ( expr , BasicMeta ) ) : return getattr ( expr , self . printmethod ) ( self , * args , * * kwargs ) # See if the class of expr is known, or if one of its super # classes is known, and use that print function for cls in type ( expr ) . __mro__ : printmethod = '_print_' + cls . __name__ if hasattr ( self , printmethod ) : return getattr ( self , printmethod ) ( expr , * args , * * kwargs ) # Unknown object, fall back to the emptyPrinter. return self . emptyPrinter ( expr ) finally : self . _print_level -= 1