Michele, thank you for the suggestion, it works as you mention. But in my case the function is inside a string and I should exec the string to get the function. Something like this
>>> fields = {} >>> s = 'def f(): pass' >>> exec s in fields >>> f = fields['f'] >>> f <function f at 0xb7a00bfc> >>> import shelve >>> d = shelve.open('test.db') >>> d['f'] = f Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/shelve.py", line 129, in __setitem__ p.dump(value) TypeError: expected string or Unicode object, NoneType found I am not a pro python developer, so I couldn't understand why it throws exception. I am a bit confused. Sincerely, Mike -- http://mail.python.org/mailman/listinfo/python-list