The following works:
def spam():
print \"spam\"
exec(spam.__code__)
spam
But what if spam
I am completely against this use of __code__.
Although I am a curious person, and this is what someone theoretically could do:
code # This is your code object that you want to execute
def new_func(eggs): pass
new_func.__code__ = code
new_func('eggs')
Again, I never want to see this used, ever. You might want to look into __import__ if you want to load code during run-time.