[Numpy-discussion] bad generator behaviour with sum
Charles R Harris
charlesr.harris at gmail.com
Sun Aug 27 14:36:40 CDT 2006
Hi,
On 8/27/06, listservs at mac.com <listservs at mac.com> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> It seems like numpy.sum breaks generator expressions:
>
> In [1]: sum(i*i for i in range(10))
> Out[1]: 285
>
> In [2]: from numpy import sum
>
> In [3]: sum(i*i for i in range(10))
> Out[3]: <generator object at 0x10eca58>
>
> Is this intentional? If so, how do I get the behaviour that I am after?
>
In [3]: sum([i*i for i in range(10)])
Out[3]: 285
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060827/6b26eccf/attachment.html
More information about the Numpy-discussion
mailing list