def dump(node, annotate_fields=True, include_attributes=False, indent='  '):
    def _format(node, level=0):
        if isinstance(node, AST):
            fields = [(a, _format(b, level + 1)) for a, b in iter_fields(node)]
            if include_attributes and node._attributes:
                fields.extend([(a, _format(getattr(node, a), level + 1))
                               for a in node._attributes])
            return ''.join([
                node.__class__.__name__,
                '(\n' + indent + indent * level if fields else '(',
                (',\n' + indent + indent * level).join(('%s=%s' % field for field in fields)
                          if annotate_fields else
                          (b for a, b in fields)),
                ')'])
        elif isinstance(node, list):
            lines = ['[']
            lines.extend((indent * (level + 2) + _format(x, level + 2) + ','
                         for x in node))
            if len(lines) > 1:
                lines.append(indent * (level + 1) + ']')
            else:
                lines[-1] += ']'
            return '\n'.join(lines)
        return repr(node)

    if not isinstance(node, AST):
        raise TypeError('expected AST, got %r' % node.__class__.__name__)
    return _format(node)
Return a formatted dump of the tree in *node*.
dataset/ETHPy150Open alecthomas/importmagic/importmagic/util.py/dump