>>> def test(): ... print("You are in the method") ... yield 1 ... print("You are again back to the method") ... yield 2 ... >>> for a in test(): ... print("You are in the block "+str(a)) ... You are in the method You are in the block 1 You are again back to the method You are in the block 2