Builtin function not working with Spyder

痞子三分冷 提交于 2019-11-26 04:01:40

问题


I\'m trying to use the max function in Python 3,6:

print(\'Maximum is:\', max(1, 3, 2, 5, 4))

And the result is

  File \"E:/ProgramyRobione/untitled1.py\", line 2, in <module>
    print(\'Maximum is:\', max(1, 3, 2, 5, 4))

TypeError: \'int\' object is not callable

I\'m using Spyder and that line is all that code should do.


回答1:


This is a bit of an iPython headshot that comes with Spyder. I've fallen foul of this when copy/pasting random bits of code from SO to test only to find really odd behaviour several days later - variables defined in the iPython console will also be in the script's global namespace indefinitely.

There's two things you can do:

  1. A hard restart of the Kernel (ctrl + .)
  2. Follow up on this feature request thread where it's now possible to clear the namespace automatically every time you run a script.


来源:https://stackoverflow.com/questions/47738537/builtin-function-not-working-with-spyder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!