Re: [Python-ideas] allow overriding files used for the input builtin

Hello, it seems that there are two independent issues – a way to temporarily replace all sys.std* streams, and a way to use the special interactive readline logic for arbitrary terminal-like file. I thought that OP's concern was the latter. In that case shouldn't there just be a way to produce an IO object f whose .readline() (or other special method) does this and has an optional prompt argument? The OP's code would become with open_terminal('/dev/tty') as f: name = f.readline(prompt='Name? ') It seems to me that changing the rather specialized input() function is wrong in both cases. For me input() is just a short way to read from the standard input, usually interactively – the same way print is a short way to write to the standard output. IIRC there was even proposal to remove input() in favor of direct use of sys.stdin.readline() at time of Python 3000 redesign. Regards, Adam Bartoš
participants (1)
-
Adam Bartoš