Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django, python: reload function in shell

I work in the django IPython-shell, which can be started with manage.py shell. When i load an extern function in the shell for testing, everything is alright. But when i make changes to the function, the shell still has the old version of the function. Even if i make a new import.

Does anyone know how to reload the actual version of the function?

Thanks in regards!

Edit: I use windows - if that makes a difference.

like image 677
Peter Avatar asked Oct 07 '10 16:10

Peter


2 Answers

I reload the module by remove it from the the sys.modules and make a new import.

import sys
sys.modules.pop('your.module')
import your.module
# or
from your.module import your_function
like image 50
wrongite Avatar answered Sep 22 '22 01:09

wrongite


try using built in "reload" function on desired module.

http://docs.python.org/library/functions.html?highlight=reload#reload

like image 24
Piotr Duda Avatar answered Sep 19 '22 01:09

Piotr Duda