def visit_JoinedStr(self, n: ast3.JoinedStr) -> Expression: # Each of n.values is a str or FormattedValue; we just concatenate # them all using ''.join. empty_string = StrExpr('') empty_string.set_line(n.lineno, n.col_offset) strs_to_join = ListExpr(self.translate_expr_list(n.values)) strs_to_join.set_line(empty_string) join_method = MemberExpr(empty_string, 'join') join_method.set_line(empty_string) result_expression = CallExpr(join_method, [strs_to_join], [ARG_POS], [None]) return result_expression
def visit_List(self, n: ast27.List) -> Union[ListExpr, TupleExpr]: expr_list: List[Expression] = [self.visit(e) for e in n.elts] if isinstance(n.ctx, ast27.Store): # [x, y] = z and (x, y) = z means exactly the same thing e: Union[ListExpr, TupleExpr] = TupleExpr(expr_list) else: e = ListExpr(expr_list) return self.set_line(e, n)
def visit_List(self, n: ast35.List) -> Node: return ListExpr([self.visit(e) for e in n.elts])
def visit_List(self, n: ast27.List) -> Union[ListExpr, TupleExpr]: expr_list = [self.visit(e) for e in n.elts] # type: List[Expression] if isinstance(n.ctx, ast27.Store): # [x, y] = z and (x, y) = z means exactly the same thing return TupleExpr(expr_list) return ListExpr(expr_list)
def visit_list_expr(self, node: ListExpr) -> Node: return ListExpr(self.nodes(node.items))
def visit_List(self, n: ast27.List) -> ListExpr: return ListExpr([self.visit(e) for e in n.elts])
def visit_list_expr(self, node: ListExpr) -> ListExpr: return ListExpr(self.expressions(node.items))
def visit_List(self, n): return ListExpr([self.visit(e) for e in n.elts])