itertools.count() as built-in
Alex Martelli
aleax at mac.com
Mon May 29 12:10:22 EDT 2006
Duncan Smith <buzzard at urubu.freeserve.co.uk> wrote:
> jantod at gmail.com wrote:
> > Zipping an xrange? I'm having trouble visualizing how you do that to
> > avoid x*i+y.
> >
> > -Janto
> >
>
> Something like,
>
> >>> lis = ['a', 'b', 'c', 'd']
> >>> y = 3
> >>> i = 7
> >>> for n, item in zip(xrange(y, len(lis)*i+y, i), lis):
> print n, item
Actually I tend to use sys.maxint as the xrange's middle arg, but, yes,
this IS the general idea!-)
Alex
More information about the Python-list
mailing list