Translate this to python?
Patrick Maupin
pmaupin at gmail.com
Tue Jan 3 21:25:54 EST 2006
> for (i = nPoints-1, j = 0; j < nPoints; i = j, j++)
Alternatively, if you don't like the initial setup of i and would
prefer your setup code at the top of the loop:
for j in range(npoints):
i = (j-1) % npoints
... (your code here)
Finally, you could always do something like this:
pointrange = range(npoints)
for i,j in zip(pointrange[-1:]+pointrange[:-1], pointrange):
... (your code here)
This latter could be useful if you are reusing the range on a regular
basis -- in fact you could store a "rotatedpointrange" as well as a
point range.
HTH,
Pat
More information about the Python-list
mailing list