[Python-Dev] a quit that actually quits

Walter Dörwald walter at livinglogic.de
Thu Dec 29 11:15:16 CET 2005


Alex Martelli wrote:

> On 12/28/05, Walter Dörwald <walter at livinglogic.de> wrote:
>   ...
>> We have sys.displayhook and sys.excepthook. Why not add a sys.inputhook?
>
> Sure, particularly with Nick's suggestion for a default input hook it would be fine.

I'd like the inputhook to be able to define the prompt. I'm not sure how this could be accomplished.

Another API would be that the inputhook returns what line or command should be executed instead, e.g.

def default_inputhook(statement):
   if statement.endswith("?"):
      return "help(%s)" % statement[:-1]
   etc.

>> > sessions in which I want to perform some action repeatedly, and currently the least typing is 4 characters (x()<enter>)
>> > while this   would reduce it to two
>>
>> What's wrong with <cursor up>, <return>?
>
> The fact that there is no upper bound to the number of cursor-up
> keystrokes needed here -- by "perform some action repeatedly" I don't mean "half a dozen times right after each other with
> nothing
> in-between" (sorry for the ambiguous phrasing), but "numerous times, repeatedly in the course of an interactive interpreter
> session".

OK, for that I've modified my .inputrc to map <page up> to incremental-search-backwards. With this it's: <x> <page up> <return>
(and it even works when the input is x("averylonginputstring")). That's not as fast as <x> <return>, but it's close.
Bye,
   Walter Dörwald





More information about the Python-Dev mailing list