Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73391
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2014-06-18 22:50 -0700 |
| References | <4045d8ca-923d-4384-a684-57cbd80ab7b7@googlegroups.com> <mailman.11118.1403118997.18130.python-list@python.org> |
| Message-ID | <03a82bc4-340f-4b16-8dbb-791b706c7862@googlegroups.com> (permalink) |
| Subject | Re: Understanding Python Code |
| From | subhabangalore@gmail.com |
On Thursday, June 19, 2014 12:45:49 AM UTC+5:30, Ian wrote: > > > > The questions are, > > > i) prev_f_sum = sum(f_prev[k]*a[k][st] for k in states) > > > here f_prev is called, > > > f_prev is assigned to f_curr ["f_prev = f_curr"] > > > f_curr[st] is again being calculated as, ["f_curr[st] = e[st][x_i] * prev_f_sum"] which again calls "prev_f_sum" > > > > > > I am slightly confused which one would be first calculated and how to proceed next? > > > > These things that you describe as "calls" are not calls. f_prev and > > f_curr are data structures (in this case dicts), not functions. > > Accessing "f_prev[k]" does not call f_prev or in any way cause > > f_prev[k] to be computed; it just looks up what value is recorded in > > the f_prev dict for the key k. > > > > Python is an imperative language, not declarative. If you want to > > know what order these things are calculated in, just follow the > > program flow. 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. Regards, Subhabrata Banerjee.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Understanding Python Code subhabangalore@gmail.com - 2014-06-18 09:36 -0700
Re: Understanding Python Code Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-18 13:15 -0600
Re: Understanding Python Code subhabangalore@gmail.com - 2014-06-18 22:50 -0700
Re: Understanding Python Code Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-19 01:00 -0600
Re: Understanding Python Code subhabangalore@gmail.com - 2014-06-19 02:48 -0700
Re: Understanding Python Code Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-19 08:09 -0600
Re: Understanding Python Code subhabangalore@gmail.com - 2014-06-19 07:27 -0700
Re: Understanding Python Code subhabangalore@gmail.com - 2014-06-19 11:44 -0700
Re: Understanding Python Code Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-19 13:07 -0600
Understanding Python Code[Forward_Backward_Wikipedia] subhabangalore@gmail.com - 2014-06-21 15:05 -0700
csiph-web