Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Deep reload for `%run` #461

Open
jedbrown opened this Issue · 10 comments

8 participants

@jedbrown

Suppose I'm editing themod.py and testing it using %run thetest.py which contains import themod. I am not aware of any current mechanism to make %run thetest.py automatically reload themod when it has changed, but this would be an extremely useful feature.

@takluyver
Owner

That makes sense, although I'm not sure how easy it would be to implement. It probably won't be sorted before 0.11, though.

@Honghe

Though 2 years has gone, 0.13.1 still hasn't deep reload for %run yet.

@takluyver
Owner

I guess no-one has felt the need strongly enough to implement it. It should be possible with autoreload, if you'd like to have a go.

@ccordoba12

For what is worth, Spyder has had this functionality for a very long time. It deletes from the current namespace and then reloads all local modules used on a given script before re-running it.

@Honghe

@ccordoba12 where is the source code of the functionality in Spyder, Thanks.

@ccordoba12

@Honghe, you can find it here. runfile is our version of %run, and UserModuleDeleter is the class in charge of reloading local modules.

For the future we are considering to replace %run with runfile for kernels managed by us.

@Honghe
@mfbx9da4

This would be extremely useful for me, means i only need one interpreter for everything! Would be great if it was just an option to the run command e.g. run -dr file.py

@jorgehatccrma

+1 for this feature request

@dashesy

If I know what is the problem hindering development of this I will gladly work on it, currently with '%autoreload 2' I get TypeError('super(type, obj): obj must be an instance or subtype of type)' any time I change a class that has a call to super. The solution could be a new %run2 comamnd that has a combination of [this answer](http://stackoverflow.com/a/2918951/311567] and Spyder's.
Here is another reload mechanism that takes care of old instances too: http://luke-campagnola.blogspot.com/2010/12/easy-automated-reloading-in-python.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.