Chris Angelico <ros...@gmail.com> writes:
> while True:
>     c = sys.stdin.read(1)
>     if not c: break
>     if c.isprintable(): text += c
>     elif c == "\x08": text = text[:-1]
>     # etc
> Can you write _that_ as a do-while?

I prefer to write that sort of thing with iterators:

 for c in iter(lambda: sys.stdin.read(1), ''):
     if c.isprintable(): text.append(c)
     elif c == '\x08': text.pop()
     ...
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to