Generators and co-routines
Simon Burton
simonb at webone.com.au
Fri Mar 7 18:12:58 EST 2003
On Fri, 07 Mar 2003 11:32:47 +0800, Simon Wittber (Maptek) wrote:
> Hello python people!
>
> I am rewriting the User class for my mud system, and am trying to use a
> generator function to simulate a co-routine, which helps me maintain
> state much more elegantly than the previous while loop with humungous
> amounts of if / elif statements.
>
> I have a server class, which loops through all connected users, calling
> the .poll() method.
>
> 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 unfamilar
> with python generators, if someone can enlighten me, please do so!
>
i'd hate to RTFM you, but it seems you don't know what your doing!
Try experimenting; you don't just "call" login... you iterate through
it... send me your code if you want.
cheers, and i'm glad your coding again :)
Simon Burton.
More information about the Python-list
mailing list