python - Using the print command and the cmd module? -


in python application, have command prompt using cmd module. have thread running in background, prints messages when needs to. however, causes conflicts. message print user typically input command. example, application typically start prompt (in case, $). when background thread prints message, printed after prompt, leaving this:

$ test message! (command typed user end here) 

if user enters command, still work fine, can confusing. instead, print line above, have this:

this test message! $ (command typed user end here) 

you need use curses ... here simple example

curses_test.py

import curses try:    w = curses.initscr()    w.addstr(5,5,"hello         ")    w.addch(7,5,">")    w.addstr(6,6,w.getstr(7,7))    w.getch() finally:    curses.endwin() 

it should exist if using linux ... windows can difficult install on


Comments