python generator hasnext