for loop possible enhancement

bob van der Poel bvdpoel at uniserve.com
Fri Sep 22 18:58:36 EDT 2000


Alex wrote:
> 
> In python2.0, you could do this:
> 
> for a, b in zip(range(1, 5), [a, b, c, d]):
>     do_stuff()
> 
> Alex.
> 
> --
> Speak softly but carry a big carrot.

Yes, read the pep. Maybe it's only me, but this looks like a very ugly
hack. I think that as a writer in the pep suggested, that

	for a in L1, b in L2:

would be much nicer. But, if the python gods can't do it that way, guess
zip() will have to do.

-- 
   __
  /  )      /         Bob van der Poel
 /--<  ____/__        bvdpoel at uniserve.com
/___/_(_) /_)         http://users.uniserve.com/~bvdpoel



More information about the Python-list mailing list