Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52672 > unrolled thread
| Started by | dieter <dieter@handshake.de> |
|---|---|
| First post | 2013-08-19 08:18 +0200 |
| Last post | 2013-08-19 08:18 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: refresing the edited python function dieter <dieter@handshake.de> - 2013-08-19 08:18 +0200
| From | dieter <dieter@handshake.de> |
|---|---|
| Date | 2013-08-19 08:18 +0200 |
| Subject | Re: refresing the edited python function |
| Message-ID | <mailman.12.1376893144.19984.python-list@python.org> |
Sudheer Joseph <sudheer.joseph@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.
Back to top | Article view | comp.lang.python
csiph-web