Generators and co-routines

Terry Reedy tjreedy at
Fri Mar 7 07:10:35 CET 2003

The .poll() method checks if the user is logged in, if not, calls the
.login() method (which is the co-routine/generator). My problem is the
.login() method is not being called! I put a print statement at the
start of the function, and nothing gets printed. I am entirely
with python generators, if someone can enlighten me, please do so!


class User:
def __init__(self, conn):
self.conn = conn
self.isLoggedIn = False

def poll(self):
if not self.isLoggedIn:

def login(self):
print "in .login()"
perhaps what you want is
self.iter = self.login # in __init__
s = # in poll
Note that login returns something that you might want to look at

Terry J. Reedy

More information about the Python-list mailing list