Holding until next value change

Arshpreet Singh arsh840 at gmail.com
Sat Aug 20 00:53:25 EDT 2016


I am writing a function as main_call() which is continuously producing values. (+ve or -ve) I want to print on screen only for first +ve value and hold until -ve value comes around. here is my code:


def main_call():
    while True:
        yield strategy()
 
for value in main_call():
    if(value>0):
        print '+ve'
    elif(value>0):
        print '-ve'
    else:
        pass 

Do I need to use threads or processes?



More information about the Python-list mailing list