Hallo, B. Bogart hat gesagt: // B. Bogart wrote:
What I am trying to accomplish is more or less this:
for x in xrange(x_upper-x_lower): for y in xrange(y_upper-y_lower): for z in xrange(z_upper-z_lower): self._outlet(1,x+x_lower) self._outlet(2,y+y_lower) self._outlet(3,z+z_lower)
All this does is step through each point in a 3D matrix of points, and output the coordinates of each point.
...
So I thought I would rewrite the script without sleep() and use an external metro to drive it.
Now I can't figure out how to write a function that I call over and over again that is identical to the above code-block except doing only one iteration at a time.
That's what generators do, available in Python since 2.3. For a quick intro see: http://www.python.org/doc/2.3.5/whatsnew/section-generators.html
They can be a bit tricky to use, until you get your head around the concept.
Attached is a quick example. It is "similar" to your problem above, but not doing the same thing, as you will see, but it should give you the idea about how generators work.
Ciao