Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101276
| Path | csiph.com!weretis.net!feeder6.news.weretis.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!gordon |
|---|---|
| From | John Gordon <gordon@panix.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Why is there difference between cmd line and .py file? |
| Date | Tue, 5 Jan 2016 20:37:33 +0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Lines | 34 |
| Message-ID | <n6h9id$6lj$1@reader1.panix.com> (permalink) |
| References | <e9f1d94f-4dd6-49b5-bf5c-bbcdc8d304e8@googlegroups.com> |
| NNTP-Posting-Host | panix1.panix.com |
| X-Trace | reader1.panix.com 1452026253 6835 166.84.1.1 (5 Jan 2016 20:37:33 GMT) |
| X-Complaints-To | abuse@panix.com |
| NNTP-Posting-Date | Tue, 5 Jan 2016 20:37:33 +0000 (UTC) |
| User-Agent | nn/6.7.3 |
| Xref | csiph.com comp.lang.python:101276 |
Show key headers only | View raw
In <e9f1d94f-4dd6-49b5-bf5c-bbcdc8d304e8@googlegroups.com> Robert <rxjwg98@gmail.com> writes:
> ////////////
> # represent the experiments
> head_counts = np.array([5,9,8,4,7])
The code doesn't define 'np', so this line should produce an error.
The code you linked contains this import:
import numpy as np
However you didn't show it here, so I wonder if you posted the real code.
> sum(expectation_A)[0]
> ---------------------------------------------------------------------------
> IndexError Traceback (most recent call last)
> <ipython-input-145-d6f33dff0343> in <module>()
> ----> 1 sum(expectation_A)[0]
> IndexError: invalid index to scalar variable.
> //////////////
The built-in function sum() returns a single value, not a list, so this
is a reasonable error.
I suspect the code actually intended to call numpy.sum(), which does
return a list (or something like a list).
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why is there difference between cmd line and .py file? Robert <rxjwg98@gmail.com> - 2016-01-05 12:25 -0800
Re: Why is there difference between cmd line and .py file? John Gordon <gordon@panix.com> - 2016-01-05 20:37 +0000
Re: Why is there difference between cmd line and .py file? Robert <rxjwg98@gmail.com> - 2016-01-05 12:45 -0800
Re: Why is there difference between cmd line and .py file? Joel Goldstick <joel.goldstick@gmail.com> - 2016-01-05 15:58 -0500
Re: Why is there difference between cmd line and .py file? Robert <rxjwg98@gmail.com> - 2016-01-05 13:05 -0800
Re: Why is there difference between cmd line and .py file? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-01-06 00:21 +0100
Re: Why is there difference between cmd line and .py file? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-01-06 16:25 +1100
Re: Why is there difference between cmd line and .py file? Robert <rxjwg98@gmail.com> - 2016-01-05 12:41 -0800
Re: Why is there difference between cmd line and .py file? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-01-06 00:25 +0100
Re: Why is there difference between cmd line and .py file? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-01-06 16:18 +1100
Re: Why is there difference between cmd line and .py file? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-01-06 16:33 +1100
csiph-web