Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73433
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!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.046 |
| X-Spam-Evidence | '*H*': 0.91; '*S*': 0.00; 'subject:Python': 0.06; 'rewrite': 0.09; 'expression,': 0.16; 'states)': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'thu,': 0.19; 'subject:Code': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'could': 0.34; 'received:google.com': 0.35; 'doing': 0.36; 'list': 0.37; 'list.': 0.37; 'to:addr:python- list': 0.38; 'list,': 0.38; 'to:addr:python.org': 0.39; 'helps': 0.61; 'line,': 0.68; 'sum.': 0.84 |
| 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=8X7fjTEpcLeVaZvRCu6+4lvOptBVS8IqoE7yIZ2jNJY=; b=Tlkrmv1uoNFmKGDBbcovzFWP/9cYoMYZ0sYSgXvbSZnwH+6UsMlD0ao/P1ZjmZ0la/ Fkqm95B00hg+2qhj7WvnUwGPAYqLgWlb8acYdfhIVKq80LYwPbkhYVIVIaYwHLsl3m5T 3iakEI2vpVo5KMyETEwe/U6AZ5nAZtvJrD4gF5ja9mXfvp1ozKWtxB7b28FIdwmQfHMQ Tyw17aDVm1lnRCgOO7qpnrmabOBjhvkI7m9Q5n1dV+qIRgQ8L1/uTCtcIK1G/+kXfnL2 RJTpkmhOmDJMTXDJzN2UmjPNr2ZXqxOkgvWWEYAzwuGjocYnfP0maaXq8n//q0XIEjzD UhrQ== |
| X-Received | by 10.236.65.227 with SMTP id f63mr8063614yhd.13.1403187023182; Thu, 19 Jun 2014 07:10:23 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <f1d47c99-b309-4ecd-8a6b-1f3b25d83370@googlegroups.com> |
| References | <4045d8ca-923d-4384-a684-57cbd80ab7b7@googlegroups.com> <mailman.11118.1403118997.18130.python-list@python.org> <03a82bc4-340f-4b16-8dbb-791b706c7862@googlegroups.com> <mailman.11131.1403161255.18130.python-list@python.org> <f1d47c99-b309-4ecd-8a6b-1f3b25d83370@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Thu, 19 Jun 2014 08:09:42 -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.11152.1403187031.18130.python-list@python.org> (permalink) |
| Lines | 17 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1403187031 news.xs4all.nl 2967 [2001:888:2000:d::a6]:43843 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:73433 |
Show key headers only | View raw
On Thu, Jun 19, 2014 at 3:48 AM, <subhabangalore@gmail.com> wrote:
> I am trying to see this line,
> prev_f_sum = sum(f_prev[k]*a[k][st] for k in states)
>
> a[k][st], and f_prev[k] I could take out and understood.
> Now as it is doing sum() so it must be over a list,
> I am trying to understand the number of entities in the list, thinking whether to put len(), and see for which entities it is doing the sum.
It's summing a generator expression, not a list. If it helps to
understand it, you could rewrite that line like this:
values_to_be_summed = []
for k in states:
values_to_be_summed.append(f_prev[k]*a[k][st])
prev_f_sum = sum(values_to_be_summed)
So the number of entities in the list is len(states).
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