Re: an enumerate question

2007-03-21 Thread Terry Hancock
[EMAIL PROTECTED] wrote: > say i want to enumerate lines of a file > eg > for n,l in enumerate(open("file")): > # print next line ie I think you'd find it much easier to move your frame of reference one line forward and think in terms of remembering the previous line, e.g.: for n,curr in en

Re: an enumerate question

2007-03-20 Thread Paulo da Silva
[EMAIL PROTECTED] escreveu: > hi > say i want to enumerate lines of a file > eg > for n,l in enumerate(open("file")): > # print next line ie > > is there a way to print out the next line from current line using the > above?. > Or do i have to do a readlines() first to get it into a list eg >

Re: an enumerate question

2007-03-19 Thread eight02645999
On Mar 20, 11:00 am, Steven Bethard <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > for n,l in enumerate(open("file")): > >print n,l # this prints current line > >print next line in this current iteration of the loop. > > Depends what you want to happen when you request "next". I

Re: an enumerate question

2007-03-19 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > for n,l in enumerate(open("file")): >print n,l # this prints current line >print next line in this current iteration of the loop. Depends what you want to happen when you request "next". If you want to renumber the lines, you can call .next() on the iterator::

Re: an enumerate question

2007-03-19 Thread Paul Rubin
[EMAIL PROTECTED] writes: > for n,l in enumerate(open("file")): >print n,l # this prints current line >print next line in this current iteration of the loop. > hope you can understand now. I see. It just seemed a little weird. If the file contains first line second line third li

Re: an enumerate question

2007-03-19 Thread skip
eight> thanks for replying. sorry i make clear again. eight> say eight> for n,l in enumerate(open("file")): eight>print n,l # this prints current line eight>print next line in this current iteration of the loop. Off the top of my head, I'd try something like: clas

Re: an enumerate question

2007-03-19 Thread eight02645999
On Mar 20, 9:48 am, Paul Rubin wrote: > [EMAIL PROTECTED] writes: > > hi > > say i want to enumerate lines of a file > > eg > > for n,l in enumerate(open("file")): > > # print next line ie > > > is there a way to print out the next line from current line using the >

Re: an enumerate question

2007-03-19 Thread Paul Rubin
[EMAIL PROTECTED] writes: > hi > say i want to enumerate lines of a file > eg > for n,l in enumerate(open("file")): > # print next line ie > > is there a way to print out the next line from current line using the > above?. I don't understand what you're trying to do. You mean you're trying

an enumerate question

2007-03-19 Thread eight02645999
hi say i want to enumerate lines of a file eg for n,l in enumerate(open("file")): # print next line ie is there a way to print out the next line from current line using the above?. Or do i have to do a readlines() first to get it into a list eg d = open("file").readlines() for n, l in enumer