Every line of 'python lambda if else' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
595 def if_else(self, cond, if_body, else_body): 596 return IfNode(self.pos, cond=cond, body=if_body, else_body=else_body)
229 def else_body(self, elsewhat): 230 if elsewhat: 231 self.write(self.newline, 'else:') 232 self.body(elsewhat)
94 def stmt(IF, EXPR, THEN, stmt): pass
466 def test_if_some_else(): 467 inc_type = Func[[IntType], IntType] 468 dec_type = Func[[IntType], IntType] 469 foo_type = Record[{'bar': Option[IntType]}] 470 env = {'inc': inc_type, 'dec': dec_type, 'foo': foo_type} 471 check_expr_type( 472 """ 473 if-some [x foo.bar] (inc x) (dec x) 474 """, 475 Tuple.typed(Union[IntType, IntType], [ 476 Symbol.typed(IF_SOME2_TYPE, 'if-some'), 477 List([ 478 Symbol('x'), 479 Tuple.typed(Option[IntType], [ 480 Symbol.typed(GET_TYPE, 'get'), 481 Symbol.typed(foo_type, 'foo'), 482 Symbol('bar'), 483 ]), 484 ]), 485 Tuple.typed(IntType, [ 486 Symbol.typed(inc_type, 'inc'), 487 Symbol.typed(Union[IntType, ], 'x'), 488 ]), 489 Tuple.typed(IntType, [ 490 Symbol.typed(dec_type, 'dec'), 491 Symbol.typed(Union[IntType, ], 'x'), 492 ]), 493 ]), 494 env, 495 )
466 def p_if_stmt(p): 467 'if_stmt : IF test COLON suite' 468 p[0] = ast.If([(p[2], p[4])], None)
332 def visitIf(self, n): 333 if not n.else_: 334 return 335 visits = [] 336 for test, code in n.tests: 337 visits.append(walk(code, Visitor(self.defines, self.uses))) 338 visits.append(walk(n.else_, Visitor(self.defines, self.uses))) 339 # compute the intersection of defines 340 self.defines = intersect([v.defines for v in visits]) 341 # compute the union of uses, perserving first occurances 342 union = {} 343 visits.reverse() 344 for v in visits: 345 union.update(v.uses) 346 union.update(self.uses) 347 self.uses = union
70 def visit_If(self, node): 71 node = self.generic_visit(node) 72 node = self.add_mask(node, node.test) 73 nodes = [node] 74 if len(node.orelse) > 0: 75 test_inverse = gast.Call( 76 gast.Attribute( 77 node.test, gast.Name('eq', gast.Load(), None), gast.Load()), 78 [gast.Num(0)], []) 79 else_node = gast.If(any_active(test_inverse), node.orelse, []) 80 node.orelse = [] 81 self.add_mask(else_node, test_inverse) 82 nodes.append(else_node) 83 node.test = any_active(node.test) 84 return nodes
340 def if_statement(self, cond, true, false=[]): 341 return IfStmt(cond=cond, true=true, false=false)
93 def enterIf_else(self, ctx:TinyPyParser.If_elseContext): 94 pass
295 def p_else_statement(p): 296 ''' 297 else_statement : ELSE statement 298 ''' 299 p[0] = Node('else', children=[p[2]])