@classmethod
    def do(self, thing, format=None):

        print_class = thing.__class__.__name__.lower()
        print_method = "_print_%s" % print_class

        if hasattr(self, print_method):
            return getattr(self, print_method)(thing, format)

        fmt = None

        if format is not None:
            fmt = format
        else:
            fmt = self._formats.get(thing.__class__.__name__.lower())

        if fmt is not None:
            sys.stdout.write((fmt + "\n") % thing.__dict__)
        else:
            sys.stdout.write(str(thing))
Smart print object depending on its type.
dataset/ETHPy150Open novel/lc-tools/lctools/printer.py/Printer.do