On 01/12/2012 12:31 PM, Mat Schaffer wrote:
> Thanks Erik and Thomas, but I think both of those solutions would
> require prepending `vars.` to all the local variable references in the
> code which is a frightening prospect. It's about 250 lines with lots of
> cross referencing of values and oddly placed list comprensions :(
> I updated https://gist.githu... to point out
> where that line is (currently 12) that I don't want to touch anything
> below. It's possible that what I have is as good as it gets, but the
> warning on first run (I suspect the compilation process) is concerning.
Instead of calling the functions directly, you could use "exec" and pass
in a dictionary of variables.
Something like this:
my_vals = locals()
# override the ones you need
my_vals['foo'] = 'bar'
# call the function with exec and pass in variables
This would allow you to override whatever you need.