Re: Holding until next value change

2016-08-26 Thread Arshpreet Singh
On Saturday, 20 August 2016 11:38:03 UTC+5:30, Steve D'Aprano wrote: > state = ignore_negative # DON'T call the function yet > for value in main_call(): > print(value) # for testing > if state(value): > print("changing state") > state = TABLE[state] Above code works at

Re: Holding until next value change

2016-08-25 Thread Arshpreet Singh
On Saturday, 20 August 2016 19:48:38 UTC+5:30, andrze...@gmail.com wrote: > prev = None > for value in main_call(): > if value==prev: > pass > else: > prev = value > if prev>0: > print('+v') > elif prev<0: > print('-v') > el

Re: Holding until next value change

2016-08-20 Thread andrzej . brozi
Hello Perhaps this would suffice: prev = None for value in main_call(): if value==prev: pass else: prev = value if prev>0: print('+v') elif prev<0: print('-v') else: print('0') Of course this will work only if su

Re: Holding until next value change

2016-08-20 Thread Arshpreet Singh
On Saturday, 20 August 2016 11:38:03 UTC+5:30, Steve D'Aprano wrote: > On Sat, 20 Aug 2016 02:53 pm, Arshpreet Singh wrote: > > > 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 -

Re: Holding until next value change

2016-08-19 Thread Steve D'Aprano
On Sat, 20 Aug 2016 02:53 pm, Arshpreet Singh wrote: > 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 Tru

Holding until next value change

2016-08-19 Thread Arshpreet Singh
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(val