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 :)

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

2 Comments

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.
That's awesome and powerful for testing! Thanks a lot for answer!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.