eliben a écrit :
   d = {}
 execcode in globals(), d
  return d['foo']

My way:

  return function(compile(code, '<string>', 'exec'), globals())


With some help from the guys at IRC I came to realize your way doesn't
do the same. It creates a function that, when called, creates 'foo' on
globals(). This is not exactly what I need.

I possibly messed up a couple things in the arguments, flags etc - I very seldom use compile() and function(). The point was that it didn't require any extra step.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to