Python: How to get input from console while an infinite loop is running? -
i'm trying write simple python irc client. far can read data, , can send data client if automated. i'm getting data in while true
, means cannot enter text while @ same time reading data. how can enter text in console, gets sent when press enter, while @ same time running infinite loop?
basic code structure:
while true: read data #here want write data if contains '/r' in
another way involves threads.
import threading # define thread takes input class inputthread(threading.thread): def run(self): self.daemon = true while true: self.last_user_input = input('input something: ') # based on user input here # alternatively, let main # self.last_user_input # main = inputthread() it.start() while true: # # it.last_user_input if feel
Comments
Post a Comment