I am using select.select() instead of input because I wanted a timeout for the input. I am using the "end" argument with the print() function because I want my terminal to have a line like this:
Type > TYPE SOMETHING HERE
Instead, I do not see "Type > " until after I type a string and press enter.
My code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#Made by Devyn Collier Johnson, NCLA, Linux+, LPIC-1, DCTS
import sys, select
print('Type > ', end=" ")
INPUT, VOID0, VOID1 = select.select([sys.stdin], [], [], 3)
if (INPUT):
print('You said, ' + sys.stdin.readline().strip())
else:
print('You said nothing!')
I am using this script to test select.select() and print(str, end=" "). I read this post (How can I suppress the newline after a print statement?) and the official Python3 documentation for both commands.