3

suppose i ask for 2 inputs:

input("Age:")
Something*
input("Name:")

But If I do this, then if I put 2 inputs. So If its asking for age and I put "5". Then while the program is doing *something, any inputs I make will go into the slot asking for Name before "Name:" even appears. How do i stop this from happening?

stavro
  • 103
  • 1
  • 5
  • 1
    Possible duplicate of [How to flush the input stream in python?](https://stackoverflow.com/questions/2520893/how-to-flush-the-input-stream-in-python) – Aran-Fey Jun 10 '17 at 20:35
  • @Rawing It is not. OP wants the buffer cleared without it being flushed to the terminal. Actually I don't believe this is possible, mainly due to the nature of `stdin`. Anyway, OP, why do you want to prevent this? – cs95 Jun 10 '17 at 20:38
  • What does OP mean? – stavro Jun 10 '17 at 21:08

1 Answers1

0

You could do something like this with the module curses

(from this post https://stackoverflow.com/a/33679981/6655211 possible duplicate)

input("Age:")

import curses
stdscr = curses.initscr()
curses.noecho()
# Something*
import time
time.sleep(5)
curses.endwin()

input("Name:")
PRMoureu
  • 12,817
  • 6
  • 38
  • 48