On Wed, Jul 16, 2008 at 8:10 PM, Alan Gauld <[EMAIL PROTECTED]> wrote:
>
> "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.

I have a different style of working, I guess. I do most work in files.
I use an editor which will easily execute the file and show the
result.

For developing functions I use a unittest, still working from one or
more files. So I rarely have to reload a module explicitly.

> 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?

No, you do have to reload the module.

> 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

I'm pretty sure that won't work. It needs a reload and the default
value for mod is bound at compile time so it will always be bound to
the old version of mycalc.

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

Reply via email to