Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52672

Re: refresing the edited python function

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'modified': 0.07; 'imported': 0.09; 'objects,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'restart': 0.09; 'thus,': 0.09; 'python': 0.11; 'changes': 0.15; '"from': 0.16; '"in': 0.16; 'object).': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'reload': 0.16; 'unchanged': 0.16; 'subject:python': 0.16; 'modification': 0.16; 'code.': 0.18; 'module': 0.19; 'solution.': 0.20; 'code,': 0.22; 'import': 0.22; '(in': 0.22; 'tests': 0.22; 'header:User-Agent:1': 0.23; 'options': 0.25; 'required.': 0.27; 'header:X-Complaints- To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'points': 0.29; 'code': 0.31; 'getting': 0.31; 'issuing': 0.31; 'reflected': 0.31; 'writes:': 0.31; 'this.': 0.32; 'running': 0.33; 'subject:the': 0.34; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'there': 0.35; 'functions.': 0.36; 'limitations': 0.36; 'module.': 0.36; 'reflect': 0.36; 'application': 0.37; 'e.g.': 0.38; 'to:addr :python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'received:org': 0.40; 'even': 0.60; 'simple': 0.61; 'further': 0.61; 'complete': 0.62; 'received:217': 0.63; 'name': 0.63; 'approaches': 0.68; 'repeat': 0.74; 'partial': 0.84; 'old,': 0.85
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From dieter <dieter@handshake.de>
Subject Re: refresing the edited python function
Date Mon, 19 Aug 2013 08:18:49 +0200
References <1376873736.85790.YahooMailNeo@web193402.mail.sg3.yahoo.com>
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host pd9e09276.dip0.t-ipconnect.de
User-Agent Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)
Cancel-Lock sha1:bNqFGsancH8H6Eef3PEu5RK9QXo=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12.1376893144.19984.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1376893144 news.xs4all.nl 15926 [2001:888:2000:d::a6]:44942
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52672

Show key headers only | View raw


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 comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: refresing the edited python function dieter <dieter@handshake.de> - 2013-08-19 08:18 +0200

csiph-web