Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

ipython has a killer autoreload function: http://ipython.org/ipython-doc/stable/config/extensions/auto...

In [1]: %load_ext autoreload

In [2]: %autoreload 2

In [3]: from foo import some_function

In [4]: some_function()

Out[4]: 42

In [5]: # open foo.py in an editor and change some_function to return 43

In [6]: some_function()

Out[6]: 43

It's nothing like a proper lisp repl, but you can sorta do this in vanilla python too, if you don't mind some annoyances. `reload` reloads a module:

>>> import mymodule

>>> print mymodule.myfunction()

3

>>> reload(mymodule)

>>> print mymodule.myfunction()

5

Downside is you have to use the module, `from mymodule import function` won't reload.



Thanks a TON! I am Frequently Slightly Annoyed by pressing control-. and having to re-import things, declare things, etc. I'm looking forward to using this.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: