0

Nice Format For Chatting Server - Python

Hey, Do any of you have a nice way/idea to make this format look normal? in my server people can send and receive text in parallel - meaning: threads. if i take inpute like so: input('You> ') and receive data like so: print(data) # data will look like: username> text text text how can i make it nice so everything will be in a new line? i tried a way that the input is: input('You> ') and the receiveing is: print(f'\n{username}> {number}', end='\nYou> ') thats the best i could do... can anyone help? look at your previous codes mybe and it might help... the threads mess eveything up...

6th Apr 2021, 12:50 PM
Yahel
Yahel - avatar
9 Respuestas
0
I had some code that did this once, but the prompt definitely wasn’t in that print statement.
6th Apr 2021, 4:19 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
You can’t really use the input function as far as I know. Use the select module.
6th Apr 2021, 4:20 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
Wilbur Jaywright may I have an example please? Isn't the select module just for the server-side? To allow serving of multiple clients?
6th Apr 2021, 4:46 PM
Yahel
Yahel - avatar
0
On linux at least, the select module checks if a file or I/O socket is ready for reading.
6th Apr 2021, 4:56 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
Wilbur Jaywright yeah, I know.. on on windows though... but what about the original question? I spent too much time on this ngl lol
6th Apr 2021, 5:02 PM
Yahel
Yahel - avatar
0
I… wasn’t entirely sure I understood the original question.
6th Apr 2021, 5:07 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
Hold on a minute! you have the prompt text in both the input and the print statement. Take it out of the print statement.
6th Apr 2021, 5:07 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
Wilbur Jaywright I know... without it it still doesn't work.. the threads mess it up...
6th Apr 2021, 5:21 PM
Yahel
Yahel - avatar
0
What exactly happens?
6th Apr 2021, 6:15 PM
Wilbur Jaywright
Wilbur Jaywright - avatar