[Tutor] Unimporting modules

Jeff Shannon jeff at ccvcorp.com
Tue Oct 21 13:24:31 EDT 2003


Hi Guillermo,

I don't know anything about how pdb works (PythonWin's integrated 
debugger is pretty much the only one I've used), so I can't really 
offer specific advice.  (If breakpoints are being retained even after 
Python is exited and restarted, then I doubt that reload()ing modules 
will help much -- maybe there's some data file that pdb is using?) 
I'm forwarding this back to the list, in hopes that someone else there 
will have some ideas...

Guillermo Fernandez wrote:

> Hi,
> 
> Thanks for the answer.
> 
> I'm trying to integrate the pdb into the editor spe
> (http://projects.blender.org/projects/spe/)
> 
> The problem is I start the python (and it works well) but when I start 
> it again, he keeps in memory all the breakpoints that I setted in the 
> previous session. I thought that to clear those, I could delete the 
> module and import it again...
> 
> Here is the Shell output:
>  >>>     # I start the debugger with Crt-P
> Running 'C:\Python23\Lib\site-packages\sm\pdbtest.py' ...
>  > <string>(1)?()
> Breakpoint 1 at c:\python23\lib\site-packages\sm\pdbtest.py:5
> (Pdb) q
> Script 'pdbtest.py' returned exit code 0
>  >>>     # I start again the debugger with Crt-P
> Running 'C:\Python23\Lib\site-packages\sm\pdbtest.py' ...
>  > <string>(1)?()
> Breakpoint 2 at c:\python23\lib\site-packages\sm\pdbtest.py:5
> (Pdb) break
> Num Type         Disp Enb   Where
> 1   breakpoint    keep yes at c:\python23\lib\site-packages\sm\pdbtest.py:5
> 2   breakpoint    keep yes at c:\python23\lib\site-packages\sm\pdbtest.py:5
> (Pdb) q
> Script 'pdbtest.py' returned exit code 0
>  >>>
> 
> As you can see, when I start again the debugger, the breakpoint added 
> has number 1 still there (I do a break and the 2 are listed...). I would 
> like to have a brand new instance of the debugger at each start :-)
> 
> I tried to reload pdb with:
>     try:
>         global pdb
>         del pdb
>     finally:
>         import pdb
> and I did the same with spedb (I extended pdb in the class spedb to 
> include breaks automatically at the start of the debugger).
> 
> Thanks in advance!
> 
> Guille
> 
> Jeff Shannon wrote:
> 
>> Guillermo Fernandez wrote:
>>
>>> Hi,
>>>
>>> I'm trying to unimport modules.
>>> [...]
>>
>>
>>
>> As Andrew Kuchling already said, that's not generally possible.  My 
>> question for you is, *why* do you want to do this?  Is there something 
>> that you're trying to accomplish by it?  If so, there may be some 
>> other way to do that.
>>
>> For instance, if you're trying to "unimport" a module so that you can 
>> then reimport it and make changes to the module show up, you can do 
>> that by calling reload(module).  If you have some other goal, there's 
>> likely another way to accomplish that, too.
>>
>> Jeff Shannon
>> Technician/Programmer
>> Credit International
>>
> 





More information about the Tutor mailing list