104078
104078

Reputation: 103

Python:Change I make on class file

Whenever I edit a class file, the new stuff does not appear when I run it.It runs the old version. The new stuff only shows up when I close Python,and open it from the beginning.

How to fix this problem?

I use Python 2.7 Canopy on Windows XP.

Upvotes: 0

Views: 48

Answers (1)

Tim Pietzcker
Tim Pietzcker

Reputation: 336128

Python imports each file only once.

So if you edit test.py and then do import test a second time, nothing changes. You need to explicitly reload the module:

>>> import test
>>> # edit test.py
>>> reload(test)    # NOT import test!

Upvotes: 1

Related Questions