Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73373

Re: Understanding Python Code

References <4045d8ca-923d-4384-a684-57cbd80ab7b7@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2014-06-18 13:15 -0600
Subject Re: Understanding Python Code
Newsgroups comp.lang.python
Message-ID <mailman.11118.1403118997.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Jun 18, 2014 at 10:36 AM,  <subhabangalore@gmail.com> 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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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