The following code produces an error (python-2.6.2). Either of the following eliminates the error:
. assign something besides mod1 (the newly-created module) to d1 . remove the call to shelve.open Why is there an error produced in the first place? What is the interaction between d1, mod1, and shelve about? This code runs without error in python-3.1 $ cat test1.py import test2 newmodule = test2.load() $ cat test2.py import imp import shelve def load(): text='import test2\n' text += '''print('hello from test3')\n''' code = compile(text,'<fake>', 'exec') mod1 = imp.new_module('newmodule') newdict = mod1.__dict__ #newdict = {} exec(code,newdict) mod1 mode = mod1 d1['unique'] = mod1 #d1['unique'] = '' return mod1 print('hello from test2') d1 = {} cache = shelve.open('persist') $ python2.6 test1.py hello from test2 hello from test3 Exception TypeError: "'NoneType' object is not callable" in ignored Exception TypeError: "'NoneType' object is not callable" in ignored -- Yorick -- http://mail.python.org/mailman/listinfo/python-list