简体   繁体   English

内置功能不适用于Spyder

[英]Builtin function not working with Spyder

I'm trying to use the max function in Python 3,6: 我正在尝试在Python 3,6中使用max函数:

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. 我正在使用Spyder,而这行代码应做的所有事情。

This is a bit of an iPython headshot that comes with Spyder. 这是Spyder附带的iPython头像。 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. 几天后,当我从SO复制/粘贴代码的随机位以进行测试以仅发现真正奇怪的行为时,我就犯规了-在iPython控制台中定义的变量也将无限期地存在于脚本的全局命名空间中。

There's two things you can do: 您可以做两件事:

  1. A hard restart of the Kernel ( ctrl + . ) 硬重启内核( 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. 跟踪功能请求线程,现在可以在每次运行脚本时自动清除名称空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM