Python - How can I run two dependant funtions at the same time?
Python - How can I run two dependant funtions at the same time? I have two funtions, one runs increasing by one a number, and the other needs to capture the number that is running the first function every 5 seconds, so that when I capture the first number is 0, the sencond one is 10, the next one is 15, and so on... this is simulating the first function as a sensor. My code is as follows: import time import threading from threading import Thread def numero(i=0): while True: i = i + 1 time.sleep(1) #print i def capturar(): while True: posicion = numero() time.sleep(5) print posicion if __name__ == '__main__': Thread(target = capturar()).start() Thread(target = numero()).start() When I run this code, it keeps in the first function, how can I get this run correctly and obtain the capture of the series of numbers every 5 seconds? First thing first, numero never returns or yields anything, so you'll always get None fr...