Traversing through variable-sized lists

2010-02-17 Thread Andrej Mitrovic
Hi, I couldn't figure out a better description for the Subject line, but anyway, I have the following: _num_frames = 32 _frames = range(0, _num_frames) # This is a list of actual objects, I'm just pseudocoding here. _values = [0, 1, 2, 3, 4] I want to call a function of _frames for each frame

Re: Traversing through variable-sized lists

2010-02-17 Thread Matt McCredie
I've tried the following workaround, but it often gives me inaccurate results (due to integer division), so I had to add a safety check: num_frames = 32 values = [0, 1, 2, 3, 4] offset_step = num_frames / len(values) for index in xrange(0, num_frames): offset = index /

Re: Traversing through variable-sized lists

2010-02-17 Thread Peter Pearson
On Wed, 17 Feb 2010 10:10:37 -0800 (PST), Andrej Mitrovic wrote: [snip] _num_frames = 32 _frames = range(0, _num_frames) # This is a list of actual objects, I'm just pseudocoding here. _values = [0, 1, 2, 3, 4] I want to call a function of _frames for each frame with a _values argument, but

Re: Traversing through variable-sized lists

2010-02-17 Thread Wolfram Hinderer
On 17 Feb., 19:10, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Hi, I couldn't figure out a better description for the Subject line, but anyway, I have the following: _num_frames = 32 _frames = range(0, _num_frames) # This is a list of actual objects, I'm just pseudocoding here.

Re: Traversing through variable-sized lists

2010-02-17 Thread John Posner
On 2/17/2010 1:10 PM, Andrej Mitrovic wrote: Hi, I couldn't figure out a better description for the Subject line, but anyway, I have the following: _num_frames = 32 _frames = range(0, _num_frames) # This is a list of actual objects, I'm just pseudocoding here. _values = [0, 1, 2, 3, 4] I want

Re: Traversing through variable-sized lists

2010-02-17 Thread Peter Otten
Andrej Mitrovic wrote: Hi, I couldn't figure out a better description for the Subject line, but anyway, I have the following: _num_frames = 32 _frames = range(0, _num_frames) # This is a list of actual objects, I'm just pseudocoding here. _values = [0, 1, 2, 3, 4] I want to call a

Re: Traversing through variable-sized lists

2010-02-17 Thread Andrej Mitrovic
On Feb 17, 8:24 pm, John Posner jjpos...@optimum.net wrote: On 2/17/2010 1:10 PM, Andrej Mitrovic wrote: Hi, I couldn't figure out a better description for the Subject line, but anyway, I have the following: _num_frames = 32 _frames = range(0, _num_frames) # This is a list of

Re: Traversing through variable-sized lists

2010-02-17 Thread Dave Angel
Andrej Mitrovic wrote: On Feb 17, 8:24 pm, John Posner jjpos...@optimum.net wrote: On 2/17/2010 1:10 PM, Andrej Mitrovic wrote: snip However the values list might have an uneven number of items. I would like to make it as evenly distributed as possible, e.g.: values =-2, -1, 0] frames

Re: Traversing through variable-sized lists

2010-02-17 Thread Andrej Mitrovic
On Feb 17, 11:56 pm, Dave Angel da...@ieee.org wrote: Andrej Mitrovic wrote: On Feb 17, 8:24 pm, John Posner jjpos...@optimum.net wrote: On 2/17/2010 1:10 PM, Andrej Mitrovic wrote: snip However the values list might have an uneven number of items. I would like to make it as evenly