PyCharm referencing older, removed variable

旧巷老猫 提交于 2020-01-04 02:43:07

问题


I just encountered an issue with PyCharm. While I did find a workaround, I'm interested to know if there's a better solution to this issue.

During development, I had a variable named rIndex. I didn't notice until today that it was throwing out the following error, sent multiple times (2-4):

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

I have no idea what would cause that, so I renamed my variable to rindex (replacing every instance), as well as removed a module-level instantiation of it; essentially removing the reference from every line of my code. (I verified this by doing a ctrl+F with the term "rIndex", case sensitive.)

When I went to re-run the script, I got the same error again, with multiple calls to it.

What would be the proper solution to fixing this issue?


My workaround was creating a new project, and copying the code over. While this worked, I would like to know a more-correct way of dealing with it (especially if future projects have multiple files and settings).


回答1:


I was facing similar issue, I realized I had watchers on my old variable. Errors were gone when I removed a variable from the watchlist.



来源:https://stackoverflow.com/questions/37753016/pycharm-referencing-older-removed-variable

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