Every line of 'python for loop shorthand' 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.
69 def test_for(): 70 src = dedent("""\ 71 for a in [1,2]: 72 a 73 74 for a1 in 1,"": 75 a1 76 """) 77 check_p(src, 1)
365 def FOR(self, node): 366 """ 367 Process bindings for loop variables. 368 """ 369 vars = [] 370 def collectLoopVars(n): 371 if hasattr(n, 'name'): 372 vars.append(n.name) 373 else: 374 for c in n.getChildNodes(): 375 collectLoopVars(c) 376 377 collectLoopVars(node.assign) 378 for varn in vars: 379 if (isinstance(self.scope.get(varn), Importation) 380 # unused ones will get an unused import warning 381 and self.scope[varn].used): 382 self.report(messages.ImportShadowedByLoopVar, 383 node.lineno, varn, self.scope[varn].source.lineno) 384 385 self.handleChildren(node)
285 def _For(self, t): 286 self.fill("for ") 287 self.dispatch(t.target) 288 self.write(" in ") 289 self.dispatch(t.iter) 290 self.body(t.body) 291 if t.orelse: 292 self.fill("else") 293 self.body(t.orelse)