python: perform a generic multi dimensional loop
<p>Python: </p>

<p>How to efficiency execute a multidimensional loop, when the number of indexes to loop is dynamic.</p>

<p>Assume an array var_size containing the size of each variable</p>

<pre><code>var_size = [ 3, 4, 5 ]
</code></pre>

<p>and a function 'loop' which will call 'f(current_state)' for each point.</p>

<pre><code>  def f(state): print state
  loop(var_size, f)
</code></pre>

<p>This call would call <em>f</em> in the following order:</p>

<pre><code> f( [ 0, 0, 0])
 f( [ 0, 0, 1])
 f( [ 0, 0, 2])
 f( [ 0, 1, 0])
 etc....
</code></pre>
