in the following code
class Student(object):
def __init__(self):
self.vals=[9,2,4,1]
def allstudents(self):
self.vals.sort()
for s in self.vals:
yield s
jack = Student()
jack.allstudents().next()
-> Of course the output is 1
jack.allstudents().next()
-> Here is the problem: this line's output is still 1. Why not 2?
jack.allstudents().next()
-> This line's output is still 1. Why not 4?
Could anyone give me an explanation, please?