2009/4/3 Anand Balachandran Pillai <abpil...@gmail.com>: > Retracted. I was testing wrong code :) It should be __builtins__, > not __builtins, in which case it fails...! > > However you can do the same thing and inject the __import__ > name after your modification. > > Like, > > code = generate_code(template) > __import__ = __builtins__.__import__ > custom_builtins.__import__ = __import__ > > env = {'__builtins__': custom_builtins} > exec(code, env)
No need to do __import__ = __builtins__.__import__ It is already available in builtins. Adding __import__ to custom_builtins solves the problem. But I'm trying to understand this curious behavior. Anand _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers