comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » How reload (re-import) a modified Python module through the IDL to Python bridge ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: How reload (re-import) a modified Python module through the IDL to Python bridge ? [message #93369 is a reply to message #93368] Mon, 27 June 2016 06:57 Go to previous messageGo to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Monday, June 27, 2016 at 2:51:26 PM UTC+1, alx wrote:
> Le lundi 27 juin 2016 15:25:54 UTC+2, Helder a écrit :
>> On Monday, June 27, 2016 at 2:13:26 PM UTC+1, alx wrote:
>>> I want to use homemade Python modules through the IDL Python bridge.
>>> While developing such a module (for instance by modifying it in Spyder IDE and running it in an IDLDE session, back and forth), I did not find the right way to (re)import the last modified version of the Python module, in order to use it again, from the still open IDL session.
>>> Is there a way, from IDL or Python side, to solve that ? How does IDL locate the module specified by its name in Python.Import method ?
>>> Thanks to anyone for any clarification.
>>> alx.
>>
>> Hi, if you're on the python 2.x side, I think that reload() might do the job.
>> https://docs.python.org/2.7/library/functions.html?highlight =reload#reload
>> There are some ways of doing this in 3.x using the "imp" module. No experience with that.
>> By the way, that's the python way. No idea if this works on the idl-python bridge! [probably not :-/]
>>
>> Cheers,
>> Helder
>
> Well. Thanks Helder.
> I am using Python 3.4. In this case, the solution (within Python) is the "importlib" module and the reload function, as you said. Spyder is likely doing that.
> But my problem is that, from the IDL side, IDL still find (through the Python.Import method) the original version of the module, not the modified one. Note that the original version should have disappeared from disk (since re-edited). Same, even after a full_reset of IDL (therefore after unloading and reloading the Python dll).
> There is likely something to do regarding Python caching, but I must say that I am just a Python newbie...
> alx.

One test could be the deleting of the .pyc file.
So if you
import myLib
then you're creating a file called myLib.pyc.
Try deleting this when you update the library...

Cheers,
Helder
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ENVI_DOIT, 'MNF_DOIT' from previous noise statistics?
Next Topic: How to use mpfitfun.pro for fitting?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:58:37 PDT 2025

Total time taken to generate the page: 0.00403 seconds