On 7/8/2016 7:17 PM, John Nagle wrote:
   If "readline" is imported, "input" gets "readline" capabilities.
It also loses the ability to import control characters.  It doesn't
matter where "readline" is imported; an import in some library
module can trigger this.  You can try this with a simple test
case:

   print(repr(input()))

as a .py file, run in a console.  Try typing "aaaESCbbb".
On Windows 7, output is "bbb".

The escape key erasing input back to the beginning of the line is Command Prompt or cmd.exe behavior. Type anything at a normal command prompt and hit ESC. Input one. It has nothing to do with Python or the readline module.

On Linux, it's "aaa\x1bbbb".

The interpretation of control characters is terminal-specific. IDLE's shell uses the same editing keys
as the editor window, which depend on OS and user customization.
Note that Python statement input is multiline, not single line.
It does not try to imitate any particular terminal and does not
normally recognize ESC.

   What's the best way to get input from the console (not any
enclosing shell script) that's cross-platform, cross-version
(Python 2.7, 3.x), and doesn't do "readline" processing?

Run Python in a cross-platform, cross-verson shell. IDLE with a fixed key set would qualifiy except a) inputting literal control chars would not work, and b) normal key sets do not work on both Mac and other systems.

I don't know how close other IDEs come.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to