Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > PythonWin: any way to delete all objects without exiting and without doing it with "del"?

Reply
Thread Tools

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

 
 
dananrg@yahoo.com
Guest
Posts: n/a
 
      03-01-2006
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?

 
Reply With Quote
 
 
 
 
Lawrence Oluyede
Guest
Posts: n/a
 
      03-01-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) writes:

> 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

--
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"
 
Reply With Quote
 
 
 
 
Steven Bethard
Guest
Posts: n/a
 
      03-01-2006
(E-Mail Removed) wrote:
> 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:

>>> list(globals())

['__builtins__', 'text', 'glob', 'pywin', 're', 'match', 'basename',
'__name__', 'line', 'foo', 'os', '__doc__', 'fn']
>>> for name in list(globals()):

.... if name != 'pywin' and name[:2] != '__':
.... del globals()[name]
....
>>> del name
>>> list(globals())

['__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
 
Reply With Quote
 
dananrg@yahoo.com
Guest
Posts: n/a
 
      03-02-2006
> 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

>>> [1,2.3]


program ends.

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

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

>>> [1,2,3]


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.

 
Reply With Quote
 
dananrg@yahoo.com
Guest
Posts: n/a
 
      03-03-2006
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?

 
Reply With Quote
 
Steven Bethard
Guest
Posts: n/a
 
      03-03-2006
(E-Mail Removed) wrote:
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
best way to "delete" all objects in a std::vector. Daniel Pitts C++ 16 06-06-2008 04:36 PM
501 PIX "deny any any" "allow any any" Any Anybody? Networking Student Cisco 4 11-16-2006 10:40 PM
delete MyClass doing more than MyClass::operator delete()? tom C++ 5 07-14-2006 06:21 PM
Finding all open filehandles and closing them before exiting Vilmos Soti Perl Misc 17 05-08-2004 11:32 PM
Exiting a loop half way through Buster Copley C++ 5 09-19-2003 03:29 PM



Advertisments