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


Groups > comp.lang.python > #73373

Re: Understanding Python Code

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'calls.': 0.09; 'python': 0.11; 'language,': 0.12; 'called,': 0.16; 'dict': 0.16; 'flow.': 0.16; 'next?': 0.16; 'recorded': 0.16; 'states)': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'slightly': 0.19; '(in': 0.22; 'subject:Code': 0.24; 'looks': 0.24; 'header :In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'calculated': 0.31; 'proceed': 0.33; 'received:google.com': 0.35; 'accessing': 0.36; 'are,': 0.36; 'functions.': 0.36; 'being': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'first': 0.61; 'here': 0.66
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=d3gx/2BGY+bm8ML6lpM0Y1ySUmpEuJ8kZU2O1ZAGxK0=; b=sHFUbWq51htxJvSIkp9uR3gpqaH7i1NtYsOQMogR5V3Nkfg3qGA9roRzvQdBzI/5LQ 2DNJ709IuoR296ByGToHJ+9QhYAzruVZtS/OrtSczfL8G2PrXlrLdOY/8qaL8MZEsuFV txAI6H1ue9chJk5BX6d8M+6emrIOdCK7x6aM0a/XxqKgbGBPLshNTtz75zuQo0o6uWtL J+Zk4VbEaOgFqyUKa4+2ML7MqDKdqTMQxLJ8FIA220iU1ZTsr/8ZEaOvVBLOZCLWuSfT bZGbkKjhfKOGl9xAVy5lWH+gucIxJfHhAfH1L/O/VihFhOjjwXAN1b45/6F65m4ok4GD xNWg==
X-Received by 10.236.65.227 with SMTP id f63mr94176yhd.13.1403118989165; Wed, 18 Jun 2014 12:16:29 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <4045d8ca-923d-4384-a684-57cbd80ab7b7@googlegroups.com>
References <4045d8ca-923d-4384-a684-57cbd80ab7b7@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 18 Jun 2014 13:15:49 -0600
Subject Re: Understanding Python Code
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11118.1403118997.18130.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1403118997 news.xs4all.nl 2975 [2001:888:2000:d::a6]:44370
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73373

Show key headers only | 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