Oooo... well done Dustin. I think we may have a winner. Here's what I came up with: https://gist.github.com/1601533#file_bettercode.py
No warnings, seems to work well. It's interesting to me is that this works with globals() but not locals(). It seems like locals() lets you set existing locals but not define new ones, but globals() can do either.
Kevin, your mention of exec is interesting as is execfile. I may be able to to use those to make my overrides even less invasive into the original code. You meant exec('foo') though right? exec(foo()) gives me an error over here.
On Thu, Jan 12, 2012 at 12:28 PM, Dustin Getz <[address removed]>
the gevent library does some funky scope stuff when it monkey patches the sockets module etc. maybe it will give you some ideas. see first 130 lines: