Re: Unbinding multiple variables

2005-01-24 Thread Johnny Lin
thanks again for all the help! especially the advice on ideas of tracking down the memory leak :). (sorry for not mentioning it earlier...i had thought deleting everything might be a quick and dirty way short-term fix. :P) best, -Johnny -- http://mail.python.org/mailman/listinfo/python-list

Re: Unbinding multiple variables

2005-01-22 Thread Nick Coghlan
Bengt Richter wrote: (OTOH, deletions of actual local bindings do seem to propagate back into a previously bound value of locals on exit, and a new call to locals() seems to return the same identical object as before, so I'm not sure I believe the , unless it has a special slot and it is automat

Re: Unbinding multiple variables

2005-01-22 Thread Bengt Richter
On 21 Jan 2005 11:13:20 -0800, "Johnny Lin" <[EMAIL PROTECTED]> wrote: >thanks everyone for the replies! > >John Hunter, yep, this is Johnny Lin in geosci :). > >re using return: the problem i have is somewhere in my code there's a >memory leak. i realize return is supposed to unbind all the loc

Re: Unbinding multiple variables

2005-01-21 Thread Steven Bethard
Alex Martelli wrote: Nevertheless, any modifications to locals() are utterly futile (within a function). Evil hack that makes modifications to locals() not quite as futile: py> import sys py> import ctypes py> def f(): ... x = 1 ... locals()['x'] = 2 ... ctypes.pythonapi.PyFrame_LocalsT

Re: Unbinding multiple variables

2005-01-21 Thread Alex Martelli
Johnny Lin <[EMAIL PROTECTED]> wrote: ... > my understanding about locals() from the nutshell book was that i > should treat that dictionary as read-only. is it safe to use it to > delete entries? Speaking as the Nutshell author: it's "safe", it just doesn't DO anything. I _hoped_ locals() wo

Re: Unbinding multiple variables

2005-01-21 Thread Steven Bethard
Johnny Lin wrote: my understanding about locals() from the nutshell book was that i should treat that dictionary as read-only. is it safe to use it to delete entries? No it's not: py> def f(): ... x = 1 ... del locals()['x'] ... print x ... py> f() 1 py> def f(): ... x = 1 ...

Re: Unbinding multiple variables

2005-01-21 Thread Johnny Lin
thanks everyone for the replies! John Hunter, yep, this is Johnny Lin in geosci :). re using return: the problem i have is somewhere in my code there's a memory leak. i realize return is supposed to unbind all the local variables, but since the memory leak is happening despite return, i thought

Re: Unbinding multiple variables

2005-01-20 Thread Leif K-Brooks
John Hunter wrote: >>>del locals()['x'] The locals() dictionary will only modify values in a module's top-level code (i.e. when the expression "locals() is globals()" is true). -- http://mail.python.org/mailman/listinfo/python-list

Unbinding multiple variables

2005-01-20 Thread Johnny Lin
Hi! Is there a way to automate the unbinding of multiple variables? Say I have a list of the names of all variables in the current scope via dir(). Is there a command using del or something like that that will iterate the list and unbind each of the variables? Thanks much! (If anyone posts an

Re: Unbinding multiple variables

2005-01-20 Thread John Machin
Johnny Lin wrote: > Hi! > > Is there a way to automate the unbinding of multiple variables? Say I > have a list of the names of all variables in the current scope via > dir(). Is there a command using del or something like that that will > iterate the list and unbind each of the variables? Yes.

Re: Unbinding multiple variables

2005-01-20 Thread John Hunter
> "Johnny" == Johnny Lin <[EMAIL PROTECTED]> writes: Johnny> Hi! Is there a way to automate the unbinding of multiple Johnny> variables? Say I have a list of the names of all Johnny> variables in the current scope via dir(). Is there a Johnny> command using del or something

Re: Unbinding multiple variables

2005-01-20 Thread Stephen Thorne
On 20 Jan 2005 19:24:43 -0800, Johnny Lin <[EMAIL PROTECTED]> wrote: > Hi! > > Is there a way to automate the unbinding of multiple variables? Say I > have a list of the names of all variables in the current scope via > dir(). Is there a command using del or something like that that will > itera