MCPcopy Create free account
hub / github.com/datacamp/pythonwhat / build_comp

Method build_comp

pythonwhat/parsing.py:698–713  ·  view source on GitHub ↗
(self, node)

Source from the content-addressed store, hash-verified

696 self.visit(node.value)
697
698 def build_comp(self, node):
699 target = node.generators[0].target
700 tv = Parser.get_target_vars(target)
701 ifs = node.generators[0].ifs
702 self.out.append(
703 {
704 "node": node,
705 "body": {"node": node.elt, "target_vars": tv},
706 "target": target,
707 "iter": node.generators[0].iter,
708 "ifs": [{"node": ifnode, "target_vars": tv} for ifnode in ifs],
709 # TODO: 'private' _target_vars, since it shouldn't be set when selecting node,
710 # see remarks in test_list_comp on rewriting
711 "_target_vars": tv,
712 }
713 )
714
715
716class ListCompParser(CompParser):

Callers 2

visit_ListCompMethod · 0.80
visit_GeneratorExpMethod · 0.80

Calls 1

get_target_varsMethod · 0.80

Tested by

no test coverage detected