(xp, fp, it, test=None)
return Node(syms.atom,
                       [Leaf(token.LBRACE, "["),
                        inner,
                        Leaf(token.RBRACE, "]")])
A list comprehension of the form [xp for fp in it if test].

    If test is None, the "if test" part is omitted.
A list comprehension of the form [xp for fp in it if test].
A list comprehension of the form [ xp for fp in it if test ] .
def ListComp(xp, fp, it, test=None):
    """A list comprehension of the form [xp for fp in it if test].

    If test is None, the "if test" part is omitted.
    """
    xp.prefix = ""
    fp.prefix = " "
    it.prefix = " "
    for_leaf = Leaf(token.NAME, "for")
    for_leaf.prefix = " "
    in_leaf = Leaf(token.NAME, "in")
    in_leaf.prefix = " "
    inner_args = [for_leaf, fp, in_leaf, it]
    if test:
        test.prefix = " "
        if_leaf = Leaf(token.NAME, "if")
        if_leaf.prefix = " "
        inner_args.append(Node(syms.comp_if, [if_leaf, test]))
    inner = Node(syms.listmaker, [xp, Node(syms.comp_for, inner_args)])
    return Node(syms.atom,
                       [Leaf(token.LBRACE, "["),
                        inner,
                        Leaf(token.RBRACE, "]")])
def ListComp ( xp , fp , it , test = None ) : xp . prefix = "" fp . prefix = " " it . prefix = " " for_leaf = Leaf ( token . NAME , "for" ) for_leaf . prefix = " " in_leaf = Leaf ( token . NAME , "in" ) in_leaf . prefix = " " inner_args = [ for_leaf , fp , in_leaf , it ] if test : test . prefix = " " if_leaf = Leaf ( token . NAME , "if" ) if_leaf . prefix = " " inner_args . append ( Node ( syms . comp_if , [ if_leaf , test ] ) ) inner = Node ( syms . listmaker , [ xp , Node ( syms . comp_for , inner_args ) ] ) return Node ( syms . atom , [ Leaf ( token . LBRACE , "[" ) , inner , Leaf ( token . RBRACE , "]" ) ] )