getting an index in a for loop
Andrew Bennetts
andrew-pythonlist at puzzling.org
Sat Feb 1 02:26:29 EST 2003
More information about the Python-list mailing list
Sat Feb 1 02:26:29 EST 2003
- Previous message (by thread): getting an index in a for loop
- Next message (by thread): IDLE on XP
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Jan 31, 2003 at 07:41:38PM -0800, Erik Max Francis wrote: > Chad Netzer wrote: > > > Or the always-in-style, oldie-but-goodie method (from Python 1.x > > onwards): > > > > s = 'abcdefg' > > for i in xrange( len( s ) ): > > print i, s[i] > > Note this solution also does not suffer from performance problem if the > sequence is truly large. I believe enumerate is like xrange, in that it lazily evaluates its results, so it should also give good performance. -Andrew.
- Previous message (by thread): getting an index in a for loop
- Next message (by thread): IDLE on XP
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list