'prettyprint a list or tuple'

def n_build_list(self, node):

    p = self.prec
    self.prec = 100
    lastnode = node.pop()
    lastnodetype = lastnode.type
    if lastnodetype.startswith('BUILD_LIST'):
        self.write('[')
        endchar = ']'
    elif lastnodetype.startswith('BUILD_TUPLE'):
        self.write('(')
        endchar = ')'
    elif lastnodetype.startswith('BUILD_SET'):
        self.write('{')
        endchar = '}'
    elif lastnodetype.startswith('ROT_TWO'):
        self.write('(')
        endchar = ')'
    else:
        raise 'Internal    Error:    n_build_list    expects    list    or    tuple'
    flat_elems = []
    for elem in node:
        if (elem == 'expr1024'):
            for subelem in elem:
                for subsubelem in subelem:
                    flat_elems.append(subsubelem)
        elif (elem == 'expr32'):
            for subelem in elem:
                flat_elems.append(subelem)
        else:
            flat_elems.append(elem)
    self.indentMore(INDENT_PER_LEVEL)
    if (lastnode.attr > 3):
        line_separator = (',\n' + self.indent)
    else:
        line_separator = ',    '
    sep = INDENT_PER_LEVEL[:(-1)]
    for elem in flat_elems:
        if (elem == 'ROT_THREE'):
            continue
        assert (elem == 'expr')
        value = self.traverse(elem)
        self.write(sep, value)
        sep = line_separator
    if ((lastnode.attr == 1) and lastnodetype.startswith('BUILD_TUPLE')):
        self.write(',')
    self.write(endchar)
    self.indentLess(INDENT_PER_LEVEL)
    self.prec = p
    self.prune()
