3

Simple python question.

When in interactive mode, I'm test an imported file, let's say I use:

from foo import foo

But in the same time I edit the code. How can I update the script which is once loaded into interactive python? When I try to reimport it, nothing happens and I'm still on my old files.

Thanks for any help.

EDIT: Ok, as I understand reload(modulename) works fine, but... What if I'm trying to reload a class with its methods? As it's written in documentation:

If a module instantiates instances of a class, reloading the module that defines the class does not affect the method definitions of the instances — they continue to use the old class definition. The same is true for derived classes.

But there's no word how to update a class methods. Any idea?

The answer's here How to reload the code of a method of class object in Python?

No more question as everything works fine now :)

Community
  • 1
  • 1
Gandi
  • 3,522
  • 2
  • 21
  • 31

1 Answers1

2

Did you take a look at this question? Reloading a changed python file in emacs python shell

Libraries in your python path can be easily updated with reload(modulename).

Community
  • 1
  • 1
markmywords
  • 683
  • 5
  • 13
  • Thanks. I only searched for update, not thinking about reloading. I've edited the question, becouse there is still an issue with this. EDIT: Found the answer, it's in main post. – Gandi Apr 12 '11 at 10:35
  • That's awesome and powerful for testing! Thanks a lot for answer! – Piotr Sobczyk Nov 09 '11 at 10:32