Sudheer Joseph <sudheer.jos...@yahoo.com> writes:

> I have been using ipython and ipython with qtconsole and working on a code 
> with functions. Each time I make a modification in function  
>
> I have to quit IPTHON console (in both with and with out qt console ) and 
> reload the function freshly. If I need to see the changed I made in the 
> function. I tried below options
> del function name
>
> import the module again  by issuing "from xxx.py import yy"
> import xxx.py
> make changes
> reload(xxx.py)
> this
>  works only if the the function in the code has same name as the code. 
> But even this do not reflect the changes made by editing the code.
> So what is the standard way to update the function for further tests after an 
> edit?

Getting changes into a running application is difficult.
Python has not been designed to make this easy.

The "reload" above is one partial way to achieve something like this.
The "reload" causes the module to be reloaded. If you have changed
the modules code, these changes will be reflected *inside* the reloaded
module. However, other modules may have imported objects from
this module (as  in your "from xxx.py import yy"). To see changes
in those objects, they, too, must repeat the import (otherwise,
they continue to use the old, unchanged object).

There is an additional approach, used e.g. by "plone.reload".
In this approach, the objects are modified "in place". All usage
points of the modified object will see changes.
However, there are (quite severe) limitations to what changes
can be made "in place". Thus, this, too, does not give a complete
solution.

In simple cases, one of those approaches can avoid a restart
after modifications. However, in general, a restart is required.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to