Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73436
| X-Received | by 10.236.101.148 with SMTP id b20mr2187574yhg.46.1403188059405; Thu, 19 Jun 2014 07:27:39 -0700 (PDT) |
|---|---|
| X-Received | by 10.50.114.161 with SMTP id jh1mr124522igb.3.1403188059191; Thu, 19 Jun 2014 07:27:39 -0700 (PDT) |
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!i13no6370532qae.1!news-out.google.com!gf2ni7igb.0!nntp.google.com!r2no5119784igi.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Thu, 19 Jun 2014 07:27:38 -0700 (PDT) |
| In-Reply-To | <mailman.11152.1403187031.18130.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=122.161.65.123; posting-account=6SonuQoAAACzSakS5dCECcJQe6ylLrzY |
| NNTP-Posting-Host | 122.161.65.123 |
| 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> <mailman.11152.1403187031.18130.python-list@python.org> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <ddd0c8c7-fb10-4ab3-8a49-3cf321777019@googlegroups.com> (permalink) |
| Subject | Re: Understanding Python Code |
| From | subhabangalore@gmail.com |
| Injection-Date | Thu, 19 Jun 2014 14:27:39 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-Received-Bytes | 3202 |
| X-Received-Body-CRC | 2729592369 |
| Xref | csiph.com comp.lang.python:73436 |
Show key headers only | View raw
On Thursday, June 19, 2014 7:39:42 PM UTC+5:30, Ian wrote: > On Thu, Jun 19, 2014 at 3:48 AM, 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). Dear Group, Thank you for your kind answer. As I put from the error I discovered it. Please see my experiment almost near to your answer. I am trying one or two questions like, why it is appending only two values at a time. If you want to assist you may kindly help me assist me. Regards, Subhabrata Banerjee. ******************************************************************************* MY EXPERIMENT ******************************************************************************* else: for k in states: print "YYY1",f_prev[k] print "YYY2",a[k][st] prev_f_sum1=f_prev[k]*a[k][st] print "YYY3",prev_f_sum1 prev_f_sum2 = sum(f_prev[k]*a[k][st] for k in states) print "YYY4",prev_f_sum2 *******************************************************************************
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