Understanding Python Code

Ian Kelly ian.g.kelly at gmail.com
Thu Jun 19 03:00:12 EDT 2014


On Wed, Jun 18, 2014 at 11:50 PM,  <subhabangalore at gmail.com> wrote:
> Thank you for the reply. But as I checked it again I found,
> f_prev[k] is giving values of f_curr[st] = e[st][x_i] * prev_f_sum
> which is calculated later and again uses prev_f_sum.

f_prev is the f_curr that was calculated on the previous iteration of
the loop.  At each iteration after the first, the script calculates
f_curr based on the value of f_prev, that is, the old value of f_curr.
Then it reassigns the newly computed f_curr to f_prev, making it now
the previous, and on the next iteration it creates a new dict to store
the next f_curr.  Does that make sense?



More information about the Python-list mailing list