The return suspends the function execution so how is it that in below example I got output: <generator object doit at 0x7f57fd2912e0> def doit(): return 0 yield 0 print(doit())