[SciPy-dev] numpy changes generator behaviour
Travis Oliphant
oliphant.travis at ieee.org
Wed Jan 11 02:37:53 CST 2006
Christopher Fonnesbeck wrote:
> I'm not sure this is intended, but it appears that numpy changes the
> behaviour of the new python 2.4 generators. Here is what is supposed
> to happen:
>
> >>> sum(x*x for x in range(10))
> 285
>
> But if I import numpy, and try again I get:
>
> >>> from numpy import *
> >>> sum(x*x for x in range(10))
> <generator object at 0x5ae90>
>
> Why should it no longer sum?
As mentioned the sum command from NumPy is being used which was
inherited from Numeric. I just improved it so that it handles
generators like this, however.
So, your example should work in current svn.
-Travis
More information about the Scipy-dev
mailing list