On Apr 28, 2:07 pm, [EMAIL PROTECTED] wrote: > Is there an elegant way to unget a line when reading from a file/stream > iterator/generator? > > By "unget" I mean a way to push back a line into the source stream and > backtrack the iterator/generator one step? > > The only alternative I can see is to put my line reading in a while-True > loop (vs. a for-loop) that manually calls my file/stream > iterator/generator's .next() method while manually handling the > StopIteration exception. Doesn't sound too elegant. > > Is there a Pythonic design pattern/best practice that I can apply here? > > Thank you, > Malcolm
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304 HTH, George -- http://mail.python.org/mailman/listinfo/python-list