Re: Modify the local scope inside a function

2006-03-01 Thread Fabio Zadrozny
Hi Sandra, Well, first, I'm not sure if you'd be interested, but Pydev Extensions (http://www.fabioz.com/pydev) should be able to make remote debugging in the way you want...Now, in order to do what you are trying to do, debuggers (or at least the pydev debugger) go for the frame you want to e

Re: Modify the local scope inside a function

2006-02-26 Thread Sandra-24
Hey Crutcher, thanks for the code, that would work. I'm now debating using that, or using function arguments to get the variables into the namespace. This would require knowing the variables in the dict ahead of time, but I suppose I can do that because it's part of the same system that creates the

Re: Modify the local scope inside a function

2006-02-25 Thread Steven D'Aprano
On Sat, 25 Feb 2006 15:53:08 -0800, Sandra-24 wrote: > Is there a way in python to add the items of a dictionary to the local > function scope? i.e. var_foo = dict['var_foo']. I don't know how many > items are in this dictionary, or what they are until runtime. Are you sure you need to do this? H

Re: Modify the local scope inside a function

2006-02-25 Thread Jason Mobarak
Sandra-24 wrote: > Is there a way in python to add the items of a dictionary to the local > function scope? i.e. var_foo = dict['var_foo']. I don't know how many > items are in this dictionary, or what they are until runtime. Why do you want to do this? Exec and eval should -not- be used for this

Re: Modify the local scope inside a function

2006-02-25 Thread Crutcher
Here you go. Unfortunate that you can't modify locals() easily, but there are other options. def foo(d): for k in d: exec '%s = %s' % (k, repr(d[k])) print a + b foo({'a':1, 'b':2}) -- http://mail.python.org/mailman/listinfo/python-list

Modify the local scope inside a function

2006-02-25 Thread Sandra-24
Is there a way in python to add the items of a dictionary to the local function scope? i.e. var_foo = dict['var_foo']. I don't know how many items are in this dictionary, or what they are until runtime. exec statements are difficult for debuggers to deal with, so as a workaround I built my code in