Silly function call lookup stuff?

simonwittber at gmail.com simonwittber at gmail.com
Wed Sep 28 10:15:01 EDT 2005


> > I guess because the function name may be re-bound between loop iterations.
> >  Are there good applications of this?  I don't know.

I have iterator like objects which dynamically rebind the .next method
in order to different things. When I want a potentially infinite
iterator to stop, I rebind its .next method to another method which
raises StopIteration. This saves lots of messy if/elif state checking
in the .next method, which I _need_ to be very fast.

>
> Yuk I'd hate that. I think it would be extremely rare.
>

I use it all the time. Dynamically rebinding methods is a nice way to
change and maintain state between calls.

Sw.




More information about the Python-list mailing list