PythonWin: any way to delete all objects without exiting and without doing it with "del"?

D

dananrg

In PythonWin, is there any way to bulk-delete all objects without using
"del object" for each, and without having to exit out of PythonWin?
 
L

Lawrence Oluyede

In PythonWin, is there any way to bulk-delete all objects without using
"del object" for each, and without having to exit out of PythonWin?

PythonWin is just an IDE. For what reason you have to delete all objects by
yourself? Garbage collector is there for that :)
 
S

Steven Bethard

In PythonWin, is there any way to bulk-delete all objects without using
"del object" for each, and without having to exit out of PythonWin?

I think you just want to modify the globals() dict:
['__builtins__', 'text', 'glob', 'pywin', 're', 'match', 'basename',
'__name__', 'line', 'foo', 'os', '__doc__', 'fn'].... if name != 'pywin' and name[:2] != '__':
.... del globals()[name]
....['__builtins__', 'pywin', '__name__', '__doc__']

Be careful though, I think there's a few things in there you might not
want to ``del`` (e.g. ``pywin``).

STeVe
 
D

dananrg

PythonWin is just an IDE. For what reason you have to delete all objects by
yourself? Garbage collector is there for that :)

I think the garbage collector is on strike. :)

Example:

# 1st execution
a = [1,2,3]
print a

program ends.

Then I comment out a = [1,2,3] and run the program:

# 2nd execution
# a = [1,2,3]
print a

Same result. Why? I know that's not a great example, but it was giving
me grief in the debugging process while using the ODBC module. I'd
really rather not have to exit out of PythonWin each time I want to
clear out all the objects I created during a script, and then
subsequently comment out for future executions of a script for
debugging, if that makes any sense.
 
D

dananrg

Steven, does your technique fix my problem? Would that delete the
objects I've created within a program if I suffix my code with it?
 
S

Steven Bethard

Steven, does your technique fix my problem? Would that delete the
objects I've created within a program if I suffix my code with it?

I'm not certain I understand your problem, but I think so. Give it a try.

STeVe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top