title: How Can I Update a String's Value without Changing Its Position with a Thread Job? [Python]
body: <p>I will have two jobs in my script. Once a job started other will run async. I used Thread for this. And this thread will return some info while other count that info.</p>
  <p>What I want to do is while counter's value is changing, thread also be continue to run.</p>
  <p>Display that I want:</p>
  <pre><code>-----------------------------------------
  Count: 5
  -----------------------------------------
  thread keeps running...
  thread keeps running...
  thread keeps running...
  </code></pre>
  <p>Actually I achive this goal using <code>curses</code> module, but this is not exactly what I wanted. Because when I press <code>^C</code> terminal contents is gone. I want them to freeze in the screen.</p>
  <p>Code with curses:</p>
  <pre class="lang-py prettyprint-override"><code>import sys
  import time
  import queue
  import signal
  import curses
  import threading
  
  
  def ctrl_c_handler(*args):
      sys.exit(0)
  
  
  signal.signal(signal.SIGINT, ctrl_c_handler)
  
  MESSAGE = &quot;thread keeps running...&quot;
  
  
  def print_func(message):
      return message
  
  
  def new_window(stdscr):
      que = queue.Queue()
  
      curses.curs_set(False)
  
      y, x = stdscr.getmaxyx()
  
      draw = x * &quot;-&quot;
  
      i = 3
      count = 1
      while True:
          thread = threading.Thread(target=lambda q, arg1: q.put(print_func(arg1)), args=(que, MESSAGE,), daemon=True)
          thread.start()
          result = que.get()
  
          try:
              stdscr.addstr(0, 0, draw)
              stdscr.addstr(1, 0, f&quot;Count: {str(count)}&quot;)
              stdscr.addstr(2, 0, draw)
              stdscr.addstr(i, 0, result)
  
          except curses.error:
              pass
  
          stdscr.refresh()
          time.sleep(0.1)
  
          i += 1
          count += 1
  
          if i == y:
              stdscr.clear()
              i = 3
  
  
  curses.wrapper(new_window)
  
  </code></pre>
  <p>Is there a way to achive the same goal without using curses, or curses with no loss of contents?</p>
  <p>Thank you!</p>