Chapter 3: Generator expressions
sammjohnsn opened this issue · comments
sammjohnsn commented
On page 76, under generator expressions, this example is shown:
In [191]: sum(x ** 2 for x in range(100))
Out[191]: 328350
However, when running the line:
sum(x ** 2 for x in range(100))
I receive the error:
"TypeError: 'int' object is not callable"
Edit:
The code only does not work in Jupyter
Wes McKinney commented
Sounds like you have a variable named sum
or range
>>> sum(x ** 2 for x in range(100))
328350
>>> sum = 5
>>> sum(x ** 2 for x in range(100))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable
Sometime in the next year I'm planning to refresh the code examples in the 2nd edition to account for pandas >= 1.1.0 and I'll make sure this is correct in the book in case there is some mistake
sammjohnsn commented
Thank you!