0

I am trying to make a simple chat system with my small, smooth, goofy ahh brain but the thing is, it's too goofy ahh. I need to print() while taking user input (input()).

def check():
    url = 'https://SwelteringTrimClasslibrary.aterx.repl.co/new_msg'

    r = eval(requests.get('https://SwelteringTrimClasslibrary.aterx.repl.co/new_msg').text)

    if not (r['auth'] == User.username):
        if not(r['cont'] == Message.content):
            setMessage(r['auth'], r['cont'])

            print(f'{Message.author}: {Message.content}')

def mainloop():
    msg = input('> ')

    setMessage(User.username, msg)

    print(f'{Message.author}: {Message.content}')

    url = 'https://SwelteringTrimClasslibrary.aterx.repl.co/new_msg'

    requests.post(url, data={'auth': Message.author, 'cont': Message.content})

while True:
    t1 = Thread(target=check)
    t2 = Thread(target=mainloop)

    t1.start()
    t2.start()

    t1.join()
    t2.join()
martineau
  • 119,623
  • 25
  • 170
  • 301
Aterx
  • 23
  • 5
  • No. Every time [this](https://SwelteringTrimClasslibrary.aterx.repl.co/new_msg) changes, I need it to print the new message, even if the user is still inputting. – Aterx Jun 16 '22 at 17:55
  • Where is this printing to appear with respect to the user's input (which I assuming is being echoed)? – martineau Jun 16 '22 at 18:12
  • Just py.exe like [this](https://i.imgur.com/gwLAKS6.png) – Aterx Jun 16 '22 at 18:25
  • The Python interpreter's interactive console isn't receiving input (beyond a few characters that might get buffered by the keyboard) at the same time it's printing output. It's performing what is known as a REPL or [Read-Eval-Print Loop](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop). The [`cmd`](https://docs.python.org/3/library/cmd.html#module-cmd) module in the standard library provides a simple framework for writing your own. – martineau Jun 16 '22 at 18:51

0 Answers0