Python Console with Python 3.4.2
I defined a function in a module which runs correctly in Python Console in PyCharm Community Edition 4.5.4:
ReloadTest.py:
def reloadtest(x):
print("Version A: {}".format(x))
Python Console:
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32
>>> from ReloadTest import reloadtest
>>> reloadtest(1)
Version A: 1
After I modified the function to "Version B", PyCharm can't find the change, and importlib.reload(ReloadTest)
gives me error.
I must reload the Python Console or restart PyCharm every time I modify a module. What did I do wrong? What is the best way to handle this?
ReloadTest.py:
def reloadtest(x):
print("Version B: {}".format(x))
Python Console:
>>> reloadtest(1)
Version A: 1
>>> from ReloadTest import reloadtest
>>> reloadtest(1)
Version A: 1
>>> import importlib
>>> importlib.reload(ReloadTest)
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'ReloadTest' is not defined
>>> from ReloadTest import reloadtest
>>> reloadtest(1)
Version A: 1
>>> import ReloadTest
>>> reloadtest(1)
Version A: 1
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…