PyCharm引用旧的、已删除的变量

PyCharm引用旧的、已删除的变量,pycharm,Pycharm,我刚刚遇到了PyCharm的问题。虽然我确实找到了解决办法,但我很想知道是否有更好的解决方案 在开发过程中,我有一个名为rIndex的变量。直到今天我才注意到它抛出了以下错误,发送了多次(2-4次): 回溯(最近一次呼叫最后一次): 文件“C:\Program Files(x86)\JetBrains\PyCharm Community Edition 2016.1.4\helpers\pydev\\u pydevd_bundle\pydevd_comm.py”,第1081行,在do_it中 结

我刚刚遇到了PyCharm的问题。虽然我确实找到了解决办法,但我很想知道是否有更好的解决方案

在开发过程中,我有一个名为rIndex的变量。直到今天我才注意到它抛出了以下错误,发送了多次(2-4次):

回溯(最近一次呼叫最后一次):
文件“C:\Program Files(x86)\JetBrains\PyCharm Community Edition 2016.1.4\helpers\pydev\\u pydevd_bundle\pydevd_comm.py”,第1081行,在do_it中
结果=pydevd_vars.evaluate_表达式(self.thread_id、self.frame_id、self.expression、self.doExec)
文件“C:\Program Files(x86)\JetBrains\PyCharm Community Edition 2016.1.4\helpers\pydev\\u pydevd\u bundle\pydevd\u vars.py”,第352行,在evaluate\u表达式中
Exec(表达式、更新的\u全局、frame.f\u局部)
文件“C:\Program Files(x86)\JetBrains\PyCharm Community Edition 2016.1.4\helpers\pydev\\u pydevd\u bundle\pydevd\u exec.py”,第3行,在exec中
全局变量、本地变量中的exec exp
文件“”,第1行
rIndex={NameError}未定义名称“rIndex”
^
SyntaxError:无效语法
我不知道这是什么原因,所以我将变量重命名为rindex(替换每个实例),并删除了它的模块级实例化;基本上从代码的每一行中删除引用。(我通过使用术语“rIndex”(区分大小写)执行ctrl+F来验证这一点。)

当我重新运行脚本时,我再次遇到同样的错误,多次调用它

解决这个问题的正确方法是什么



我的解决方法是创建一个新项目,然后复制代码。虽然这样做有效,但我想知道一种更正确的处理方法(特别是如果将来的项目有多个文件和设置)。

当我面临类似问题时,我意识到我的旧变量上有监视者。当我从观察列表中删除一个变量时,错误就消失了

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.4\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 1081, in do_it
    result = pydevd_vars.evaluate_expression(self.thread_id, self.frame_id, self.expression, self.doExec)
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.4\helpers\pydev\_pydevd_bundle\pydevd_vars.py", line 352, in evaluate_expression
    Exec(expression, updated_globals, frame.f_locals)
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.4\helpers\pydev\_pydevd_bundle\pydevd_exec.py", line 3, in Exec
    exec exp in global_vars, local_vars
  File "<string>", line 1
    rIndex = {NameError}name 'rIndex' is not defined
                           ^
SyntaxError: invalid syntax