About 50 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

    26 Since a for loop is a statement (as is print, in Python 2.x), you cannot include it in a lambda expression. Instead, you need to use the write method on sys.stdout along with the join method.

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

    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 like …

  4. for loop in Python - Stack Overflow

    60 You should also know that in Python, iterating over integer indices is bad style, and also slower than the alternative. If you just want to look at each of the items in a list or dict, loop directly …

  5. python - How to stop one or multiple for loop (s) - Stack Overflow

    I find it easier to understand with the use of a loop and it will stop both for loops that way. The code below also return the True/False as asked when the function check_nxn_list () is called. …

  6. python - Get loop count inside a for-loop - Stack Overflow

    Get loop count inside a for-loop [duplicate] Asked 15 years, 5 months ago Modified 3 years, 7 months ago Viewed 654k times

  7. python - Lambda in a loop - Stack Overflow

    The selected solution helped me a lot, but I consider necessary to add a precision to make functional the code of the question: define the lambda function outside of the loop.

  8. 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): …

  9. How to find the maximum number in a list using a loop?

    # using for loop to go through all items in the list and assign the smallest value to a variable, which was defined as min. Note: the above code is to pick up the max and min by using for loop, …

  10. Efficient way of having a function only execute once in a loop

    Nov 5, 2010 · If the condition check needs to happen only once you are in the loop, having a flag signaling that you have already run the function helps. In this case you used a counter, a …