Python Forum
gnureadline: disable temporarily? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: gnureadline: disable temporarily? (/thread-9994.html)



gnureadline: disable temporarily? - klaymen - May-08-2018

Hi all,

I'm using the gnureadline module (under Python 2.7) to allow input editing for a shell-like environment. However, when larger copy buffers should be sent, the added gnureadline features are more of a burden (escaping characters etc), so I look for a way to turn off the whole gnureadline temporarily, something like (simplified)

import gnureadline
while True:
    line = raw_input('')
    if line.startswith(":r"): # raw mode
        <turn off gnureadline>
    if line.startswith(":g"): # gnu mode
        <turn on gnureadline>
    if line == 'stop':
        break
    print 'ENTERED: "%s"' % line
Is there a way to do this? There are of course workarounds, like reading from file (which I currently use), but I still wonder.

Thanks in advance,

Andy


RE: gnureadline: disable temporarily? - Larz60+ - May-08-2018

Maybe: http://python-prompt-toolkit.readthedocs.io/en/stable/
or, python 3.6.5??