Python Forum
gnureadline: disable temporarily?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
gnureadline: disable temporarily?
#1
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
Reply
#2
Maybe: http://python-prompt-toolkit.readthedocs.io/en/stable/
or, python 3.6.5??
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Errors when trying to disable tkinter checkbutton rrick_88 7 2,835 Feb-17-2022, 10:30 PM
Last Post: deanhystad
  temporarily buffer output, and output it later rowan_bradley 5 2,903 Mar-24-2021, 08:45 PM
Last Post: deanhystad
  Temporarily storing the value of a function Men 6 2,781 Jun-21-2020, 06:43 PM
Last Post: Men
  an easy way to disable exception handling Skaperen 6 5,416 Jun-02-2019, 10:38 PM
Last Post: Gribouillis
  disable a block of code Skaperen 5 13,207 Aug-20-2018, 07:55 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020