indexed() generator
Raymond Hettinger
othello at javanet.com
Fri Jan 25 00:35:23 EST 2002
FWIW, I give this idea a +1.
Please include some form of iterindexed(seq, start=0) as a built-in in
Python2.3.
I've been coding something like this in many of my programs since 2.2 came
out.
Raymond
> > In article <mailman.1011750813.24541.python-list at python.org>, Delaney,
> > Timothy wrote:
> >
> > >A perhaps better method would be:
> > >
> > >def indexed (seq, start=0)
> > > i = start
> > > for obj in seq:
> > > yield i, obj
> > > i += 1
More information about the Python-list
mailing list