Re: [Tutor] updating step size while in loop

2012-07-10 Thread Alan Gauld
On 09/07/12 22:59, Abhishek Pratap wrote: I want to know whether it is possible for dynamically update the step size in xrange or someother slick way. Here is what I am trying to do, if during a loop I find the x in list I want to skip next #n iterations. You could use the next() method of t

Re: [Tutor] updating step size while in loop

2012-07-09 Thread Wayne Werner
While you can't do it with a straight generator, you can create your own: class MyIter: def __init__(self, start, stop, step=1): self.start = start self.stop = stop self.step = step def __iter__(self): self.cur = self.start while self.cur < self.sto

Re: [Tutor] updating step size while in loop

2012-07-09 Thread Abhishek Pratap
Ok thanks Hugo. I have the while loop working -A On Mon, Jul 9, 2012 at 3:06 PM, Hugo Arts wrote: > On Mon, Jul 9, 2012 at 11:59 PM, Abhishek Pratap > wrote: >> >> hey guys >> >> I want to know whether it is possible for dynamically update the step >> size in xrange or someother slick way. >>

Re: [Tutor] updating step size while in loop

2012-07-09 Thread Hugo Arts
On Mon, Jul 9, 2012 at 11:59 PM, Abhishek Pratap wrote: > hey guys > > I want to know whether it is possible for dynamically update the step > size in xrange or someother slick way. > > Here is what I am trying to do, if during a loop I find the x in list > I want to skip next #n iterations. > >

[Tutor] updating step size while in loop

2012-07-09 Thread Abhishek Pratap
hey guys I want to know whether it is possible for dynamically update the step size in xrange or someother slick way. Here is what I am trying to do, if during a loop I find the x in list I want to skip next #n iterations. for x in xrange(start,stop,step): if x in list: step = 14