"Dick Moores" <[EMAIL PROTECTED]> wrote

Caveat: I have no experience with IPython whatsoever.

I have a big, 2000-line module, mycalc.py  that is a collection of
useful functions, most written by myself. I often import one or
another function from it and use it in the Ulipad shell. Then I see
that the function needs a small revision. I modify it in the module,
then want to test it and then use the new version in the shell. I'd like
to be able to do this in IPython.

OK, If you only import the functions not the whole module reload
won't work. But how about deleting the function and then
re-importing it? Wouldn't that do it?

You could even create a function to do that for you, maybe like:

def restart(fn, mod=mycalc):
   del fn
   from mod import fn
   return fn

And us it like:

from mycalc import foo,restart
foo(42)   # oops wrong result
# go edit foo
foo = restart(foo)
foo(42)   # thats better...

This is untested pseudo code but it should work with a bit of
effort - eg. you may need to use the programatic mechanism for
re importing

Just a thought.

Alan G

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to