Exemple #1
0
 def p_argument_colonequal(self, p):
     """argument : test COLONEQUAL test"""
     p1 = p[1]
     store_ctx(p1)
     p[0] = ast.NamedExpr(target=p1,
                          value=p[3],
                          lineno=p1.lineno,
                          col_offset=p1.col_offset)
Exemple #2
0
 def p_namedexpr_test(self, p):
     """namedexpr_test : test
                       | test COLONEQUAL test
     """
     if len(p) == 2:
         p[0] = p[1]
     else:
         p1 = p[1]
         store_ctx(p1)
         p[0] = ast.NamedExpr(target=p1,
                              value=p[3],
                              lineno=p1.lineno,
                              col_offset=p1.col_offset)