On 2021-04-05 2:25 PM, Bischoop wrote:
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())
The 'yield' in the function makes the function a 'generator' function.
'Calling' a generator function does not execute the function, it returns
a generator object.
You have to iterate over the generator object (e.g. by calling next() on
it) in order to execute the function and return values.
Frank Millman
--
https://mail.python.org/mailman/listinfo/python-list