About 152,000 results
Open links in new tab
  1. python - Creating functions (or lambdas) in a loop (or …

    Basically "i is not local to the loop but a global variable". At Late Binding Closures gotchas we read Python’s closures are late binding. This means that the values of variables used in …

  2. python - loop for inside lambda - Stack Overflow

    May 11, 2022 · I need to simplify my code as much as possible: it needs to be one line of code. I need to put a for loop inside a lambda expression, something like that: x = lambda x: (for i in x …

  3. python - How to repeatedly execute a function every x seconds?

    506 I want to repeatedly execute a function in Python every 60 seconds forever (just like an NSTimer in Objective C or setTimeout in JS). This code will run as a daemon and is effectively …

  4. How do I parallelize a simple Python loop? - Stack Overflow

    Mar 20, 2012 · This is probably a trivial question, but how do I parallelize the following loop in python? # setup output lists output1 = list() output2 = list() output3 = list() for j in range(0, 10): …

  5. python - How can I use `return` to get back multiple values from a …

    Jul 4, 2020 · This question has become a canonical duplicate target for questions about returning multiple values from code including a for loop. As such, I have edited it somewhat artificially, to …

  6. What does the "yield" keyword do in Python? - Stack Overflow

    Oct 24, 2008 · Yield in Python used to create a generator function. Generator function behaves like an iterator, which can be used in loop to retrieve items one at a time. When a generator …

  7. For loop and zip in python - Stack Overflow

    Is it like a 2d for loop? why we need the zip? Can we have 2d loop with out zip function? Q2-I am not understanding how x:y works! the compile understand automatically that the definition of x …

  8. Are infinite for loops possible in Python? - Stack Overflow

    Is it possible to get an infinite loop in for loop? My guess is that there can be an infinite for loop in Python. I'd like to know this for future references.

  9. python - return statement in for loops - Stack Overflow

    31 Your problem is, precisely, that you're putting the return statement inside the for-loop. The for-loop runs each statement in it for however so many times.. if one of your statements is a …

  10. python - How do you run your own code alongside Tkinter's event …

    Tkinter, however, hogs the time for its own event loop, and so his code won't run. Doing root.mainloop() runs, runs, and keeps running, and the only thing it runs is the event handlers. …