Re: import vs imp and friends.

2009-07-24 Thread Emanuele D'Arrigo
Christian, Robert, thank you both for the replies, much appreciated. Manu -- http://mail.python.org/mailman/listinfo/python-list

import vs imp and friends.

2009-07-23 Thread Emanuele D'Arrigo
Greetings, I was looking in the archive of this newsgroup and I found this snippet: import imp sourcecode = 'def foo(x): return 11*x' mod = imp.new_module('foo') exec sourcecode in mod.__dict__ mod.foo(16) Together with similar and sometimes more complete snippets available they show how a

Re: import vs imp and friends.

2009-07-23 Thread Christian Heimes
Emanuele D'Arrigo wrote: Now the question. Apart from checking sys.module first and eventually adding the new module to it if it isn't there already, and apart from setting __file__, is there anything else that import does and this snippet doesn't? The import statement does several things.

Re: import vs imp and friends.

2009-07-23 Thread Robert Kern
On 2009-07-23 09:44, Emanuele D'Arrigo wrote: Greetings, I was looking in the archive of this newsgroup and I found this snippet: import imp sourcecode = 'def foo(x): return 11*x' mod = imp.new_module('foo') exec sourcecode in mod.__dict__ mod.foo(16) Together with similar and sometimes more