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

Re: enumerate() question

2006-05-22 Thread Robert Kern
Gregory Petrosyan wrote: > Hello! > I have a question for the developer[s] of enumerate(). Consider the > following code: > > for x,y in coords(dots): > print x, y > > When I want to iterate over enumerated sequence I expect this to work: > > for i,x,y in enumerate(coords(dots)): > print

Re: enumerate() question

2006-05-22 Thread Gregory Petrosyan
Thanks a lot. -- http://mail.python.org/mailman/listinfo/python-list

Re: enumerate() question

2006-05-22 Thread Diez B. Roggisch
Gregory Petrosyan wrote: > Hello! > I have a question for the developer[s] of enumerate(). Consider the > following code: > > for x,y in coords(dots): > print x, y > > When I want to iterate over enumerated sequence I expect this to work: > > for i,x,y in enumerate(coords(dots)): > prin

Re: enumerate() question

2006-05-22 Thread Damjan
> I have a question for the developer[s] of enumerate(). Consider the > following code: > > for x,y in coords(dots): > print x, y > > When I want to iterate over enumerated sequence I expect this to work: > > for i,x,y in enumerate(coords(dots)): > print i, x, y for i, (x, y) in enumera

Re: enumerate() question

2006-05-22 Thread Leif K-Brooks
Gregory Petrosyan wrote: > Hello! > I have a question for the developer[s] of enumerate(). Consider the > following code: > > for x,y in coords(dots): > print x, y > > When I want to iterate over enumerated sequence I expect this to work: > > for i,x,y in enumerate(coords(dots)): > print

Re: enumerate() question

2006-05-22 Thread Laurent Pointal
Gregory Petrosyan a écrit : > Hello! > I have a question for the developer[s] of enumerate(). Consider the > following code: > > for x,y in coords(dots): > print x, y > > When I want to iterate over enumerated sequence I expect this to work: > > for i,x,y in enumerate(coords(dots)): > pr

enumerate() question

2006-05-22 Thread Gregory Petrosyan
Hello! I have a question for the developer[s] of enumerate(). Consider the following code: for x,y in coords(dots): print x, y When I want to iterate over enumerated sequence I expect this to work: for i,x,y in enumerate(coords(dots)): print i, x, y Unfortunately, it doesn't =( and I