You need to disable canonical mode of TTY which can be done using termios.
This will allow you to get lines loner than 4096 but you won't be able to edit lines using arrows, backspaces, etc.
import sys
import termios
def get_line(prompt=""):
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
new = termios.tcgetattr(fd)
new[3] = new[3] & ~termios.ICANON
try:
termios.tcsetattr(fd, termios.TCSADRAIN, new)
line = input(prompt)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old)
return line
str = get_line('test: ')
print('len: {}'.format(len(str)))
print(str)
It is the same as
stty -icanon