A question about generators

Richard J Kuhns rjk at grauel.com
Thu Mar 21 10:50:57 EST 2002


Tim Peters <tim.one at comcast.net> writes:

> [Richard J Kuhns]
> > That's pretty much what I ended up doing -- I put a "while 1:" loop
> > around the rest of the code in the generator, and I test a "reset
> > generator" variable after each yield.  If it's set, "continue" the
> > while loop. It's kind of nasty-looking, but it seems to work.
> 
> Make the generator a method of a class.  Give class instances a "reset
> generator" variable.  Give the class a reset() method to set this variable.
> Then it's all nice, abstracted, reusable, and self-contained.
> 
> a-feature-in-isolation-is-a-feature-doomed-to-misuse-ly y'rs  - tim
> 
That's EXACTLY what I did :).  The main reason I had problems to start with
is that almost everything I've done with python feels more-or-less
"elegant", and this doesn't.  Like I said, though, it works and it's pretty
much hidden from view.

-- 
Richard Kuhns			rjk at grauel.com
PO Box 6249			Tel: (765)477-6000 \
100 Sawmill Road				    x319
Lafayette, IN  47903		     (800)489-4891 /

______________________________________________________________________
Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com
   With NINE Servers In California And Texas - The Worlds Uncensored News Source
  



More information about the Python-list mailing list