开发者

How can I update a source file (with classes) in interactive python

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜