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


Groups > comp.lang.python > #52737

RE: refresing the edited python function

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ramit.prasad@jpmorgan.com>
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; 'subsequent': 0.05; 'completeness': 0.07; 'skip:` 10': 0.07; '[1]:': 0.09; '[2]:': 0.09; '[3]:': 0.09; 'received:155': 0.09; 'python': 0.11; 'stored': 0.12; '"from': 0.16; '[4]:': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'helps.': 0.16; 'imported.': 0.16; 'received:155.180': 0.16; 'received:159': 0.16; 'received:159.53': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'reload': 0.16; 'securities,': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'subject:python': 0.16; 'modification': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'module': 0.19; 'trying': 0.19; '>>>': 0.22; 'import': 0.22; '(in': 0.22; 'to:name:python-list@python.org': 0.22; 'creating': 0.23; 'instead.': 0.24; 'module,': 0.24; 'source': 0.25; 'options': 0.25; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'am,': 0.29; "doesn't": 0.30; 'moved': 0.30; 'code': 0.31; 'issuing': 0.31; 'loading': 0.31; 'file': 0.32; 'received:169.254': 0.32; 'subject:the': 0.34; 'created': 0.35; 'test': 0.35; 'accuracy': 0.36; 'functions.': 0.36; 'module.': 0.36; 'object,': 0.36; 'returning': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'received:169': 0.37; 'easily': 0.37; 'to:addr:python-list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'changed': 0.39; 'hope': 0.61; 'new': 0.61; 'information,': 0.61; 'simply': 0.61; 'first': 0.61; 'name': 0.63; 'refer': 0.63; 'purchase': 0.65; 'subject': 0.69; 'legal': 0.71; 'sale': 0.75; "'foo'": 0.84; 'functions:': 0.84; 'imp': 0.84; 'or:': 0.84; 'received:169.254.8': 0.84
X-DKIM OpenDKIM Filter v2.1.3 sz4.jpmchase.com r7KF8pNI015112
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1377011331; bh=MH9rZ7YNBPgtzPBBHzeFDHi/OHD5FVRc502LNSlVDGA=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:content-transfer-encoding:MIME-Version; b=NQ1uPydCGD5SB6Nsmzc/BXmOOUMBW3dAixc6qhB5FHOK2d/zzcG+R7khFUzwzO01+ 9FOz/QeRgN+GN/zFpAQ7+3qWs5pNQIZkAUSsHS9/IajGbKJto7fU/AnygJd7SAP66X rqDW309JkvG5m/DHmPC2QHLVfnL5TpVvbIUDfKp8=
X-AuditID a959a26a-b7fc68e0000023ec-8a-521386810355
From "Prasad, Ramit" <ramit.prasad@jpmorgan.com.dmarc.invalid>
To "python-list@python.org" <python-list@python.org>
Subject RE: refresing the edited python function
Thread-Topic refresing the edited python function
Thread-Index AQHOnXMazhc7jGa+rEm0mc50BzCUoJmeMzCg
Date Tue, 20 Aug 2013 15:08:48 +0000
References <mailman.10.1376875558.19984.python-list@python.org> <kuv48f$ed5$1@dont-email.me>
In-Reply-To <kuv48f$ed5$1@dont-email.me>
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.67.79.47]
Content-Type text/plain; charset="us-ascii"
content-transfer-encoding quoted-printable
MIME-Version 1.0
X-DLP-FWD Yes
X-Brightmail-Tracker H4sIAAAAAAAAA+NgFvrIKsWRmVeSWpSXmKPExsUye4sJr25Tm3CQwcwv4hZHWq+xOjB6vJj/ hi2AMaqB0SYxLy+/JLEkVSEltTjZVsklszg5JzEzN7VIQVfBqyA3vyg9MU8vOT9XSSEzxVbJ REmhICcxOTU3Na/EVimxoCA1L0XJjksBA9gAlWXmKaTmJeenZOal2yp5BvvrWliYWuoaKtmF ZGQWK6TmJmbmKCRsZM+4PvMEa8FHwYrtn9exNTCu5O1i5OSQEDCRuHzxGiOELSZx4d56ti5G Lg4hgSOMEpMPH4FyDjNKPGtcxgThbGaUaDl3mAWkhU3AUOL42SfsILaIgKnE65W7WUFsYaD4 rqenGSHiRhIPV62As5/cXgZWwyKgKnHkw0Q2EJtXIERi8bpVYDOFBOIlZqyZCVbPKaApsfvP TrA4I9B530+tYQKxmQXEJW49mc8EcbaAxJI955khbFGJl4//sULY8hIvprxkg6jXkViw+xOU rS2xbOFrZoi9ghInZz4Bms8BtFdNYt96WxBTQoBPYntb9QRGiVlIls1CMmgWkkGzkAxawMiy ilGyODc9zVSvuKxIr7RYL6sgNzkjsThVLy+1ZBMjMKWsjFyUtYPx3CLbQ4wCHIxKPLw7KoSD hFgTy4orcw8xSnAwK4nwzpM4FCjEm5JYWZValB9fVJqTWnyIsQoYZhOZpUST84HpLq8k3tDY zMLA1NTQwMLQyIQqwkrivPtzuYOEBNKBSTU7NbUgtQhmORMHp1QD43k2BaOpPYEt9fn1XSFz Gc98Yba1md2/PP/l0UltRjkiFdlzHDPqtFZMnD4986Ks0KVTC0WtwhOi5upPTIp0jtzj+m1N 4wXef8or7xZU/XSxfGY2h93c7PiFu3tvtRnyqqy++6p27flLMUJ/a0rXTfrz0qquZc0TkY8h U3WONjkeunHPekb+EiWW4oxEQy3mouJEAKc/d1uEAwAA
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.61.1377013094.19984.python-list@python.org> (permalink)
Lines 79
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1377013094 news.xs4all.nl 15921 [2001:888:2000:d::a6]:57763
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52737

Show key headers only | View raw


alex23
> 
> On 19/08/2013 10:55 AM, Sudheer Joseph wrote:
> > 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"
> 
> This doesn't re-import the module if xxx has already been imported. It
> simply rebinds xxx.yy to yy.
> 
> > import xxx.py
> 
> This also doesn't re-import the module if it has already been imported.
> 
> When you import a module, or a function from a module, a module object
> is created and stored in sys.modules. Any subsequent 'import <module>'
> calls will return a reference to that module object, and won't reload
> from file at all.
> 
> You can easily verify this by creating a test module 'foo' with a single
> line of `print('loading foo')` and then trying this from the console:
> 
>      In [1]: import foo
>      loading foo
> 
>      In [2]: del foo
> 
>      In [3]: import foo
> 
>      In [4]:
> 
> Note that you only see 'loading foo' the first time you import the
> module. In order to have the module loaded again rather than returning
> the existing reference, you would use `reload(foo)`:
> 
>      In [5]: reload(foo)
>      loading foo
> 
> So: in order to be able to use functions from a re-loaded module, you
> should always refer to them via the module object, and not import them
> directly:
> 
>      >>> import xxx
>      >>> xxx.yy() # original code
>      # ...modify function `yy` in your source file
>      >>> reload(xxx)
>      >>> xxx.yy() # new code
> 
> Or: you can reload the module and then rebind the functions:
> 
>      >>> from xxx import yy
>      >>> yy() # original code
>      # ...modify function `yy` in your source file
>      >>> reload(xxx)
>      >>> from xxx import yy
>      >>> yy() # new code
> 
> Hope this helps.
> 
> --

In Python 3 the reload built-in was moved to the imp module.
So use imp.reload(<module>) instead.


~Ramit



This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email.  

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

refresing the edited python function Sudheer Joseph <sudheer.joseph@yahoo.com> - 2013-08-19 08:55 +0800
  Re: refresing the edited python function alex23 <wuwei23@gmail.com> - 2013-08-20 17:01 +1000
    RE: refresing the edited python function "Prasad, Ramit" <ramit.prasad@jpmorgan.com.dmarc.invalid> - 2013-08-20 15:08 +0000

csiph-web