In Python 2 there was an error when return was together with yield in function definition. But for this code in Python 3.3
def f():
return 3
yield 2
x = f()
print(x.__next__())
there is no error that return is used in function with yield. However when the function __next__
is called then there is thrown exception StopIteration. Why there is not just returned value 3
? Is this return somehow ignored?