ungetch in Python

Erik Max Francis max at alcyone.com
Wed Dec 24 18:23:51 EST 2003


Scott Fenton wrote:

> I'm writing a small parser for a minilanguage in Python,
> and I was wondering --- is there any equiv. of C's ungetch
> or Scheme's peek-char in python? That is, is there a way to
> look at a character without taking it off of the input stream
> or is there a way to put it back on the input stream afterwards?
> I googled around and didn't come up with anything that didn't
> involve curses, which I don't want to use. Any help?

Not internally but it's awfully easy to write a wrapper around a file
class which does this.

-- 
 __ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/  \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
\__/ Conversation is the enemy of good wine and food.
    -- Alfred Hitchcock




More information about the Python-list mailing list