I am not maintaining this; it my not work or have bugs on the latest version of python.
This defines a decorator that causes the variable result
to be automatically returned from a function when there is no return statement.
This works by getting the source code of the decorated function, so this won't work in the CPython REPL. It does work in IPython however.
Inspired by the Nim feature that does the same thing.
>>> from return_result import return_result
>>> @return_result
... def test():
... result = "Works!"
>>> test()
'Works!'
Python 3.6+