what follows is what Dapwnzor was discussing:
not quite sure what you are trying to do with drawing and such, but as far as looping goes, the simplest way is to do it like this:
Code
for frame in framelist:
do_something(frame)
For example if your framelist = ["dog", "cat", "mouse"], this will call the do_something function once as do_something("dog"), then do_something("cat"), then do_something("mouse"). It actually does not matter what the framelist is composed of... in fact here is another example:
Code
wootybooty = "I like turtles"
for letter in wootybooty:
print letter
This prints the string "I like turtles", one letter at a time.
A more confusing example:
Code
List_of_lists=[[1,2,3],[4,5,6],[7,8,9]]
for list in list_of_lists:
print list
This time, on each loop you will print out a whole list, on the first loop it will print [1,2,3], and on the second it will print [4,5,6], and on the 3rd it will print [7,8,9]
however, this one will fail with an error:
Code
my_fav_number = 655321
for number in my_fav_number:
print number
Python does not understand that you want it to look at the number digit by digit. I assume this is because it does not actually use numbers in base 10, so the "breaking point" between the digits would be different in binary than they are in base 10; so there is no obvious way to break them up like there was for lists and strings and such. If you really must do this here is how you can do it:
Code
my_fav_number = 655321
temp_string_fav_number = str(my_fav_number)
for number in temp_string_fav_number:
print int(number)
With a dirty trick we converted to string, spit it, then converted back.
another userful example might be this:
Code
for i, frame in enumerate(framelist):
do_something(frame)
This one is a little harder to explain, but it works the same as the first one, except you also have access to the index number of the current frame (from framelist) as "i" on each loop. This one is very useful.
This post was edited by Azrad on Oct 28 2013 10:03pm