The following works:
def spam(): print \"spam\" exec(spam.__code__)
spam
But what if spam
My method, I thing it`s more beautiful
def f(x): print(x, x+1) g = type(f)(f.__code__, globals(), "optional_name") g(3)