[on topic] Re: readline trick needed
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Oct 16 07:27:37 EDT 2012
On Tue, 16 Oct 2012 10:30:01 +0200, Peter Otten wrote:
> Steven D'Aprano wrote:
>
>> I'm working with the readline module, and I'm trying to set a key
>> combination to process the current command line by calling a known
>> function, *and* enter the command line.
>>
>> Something along the lines of:
>>
>> * execute function spam() in some context where it can access
>> the current command line as a string
>> * enter the command line
>>
>> Function spam() may or may not modify the command line.
>
>> (P.S. I'm aware of IPython, I want to get this working in the standard
>> CPython interpreter.)
>
> If IPython does what you want why don't you have a look at the source?
Well, I was hoping for a pure Python solution, rather than having to
troll through who knows how many thousands of lines of code in a language
I can barely read.
> Anyway, here's what I came up with (no warranties as it was all
> trial-and- error):
>
> $ cat readline_callback.py
> import ctypes
Ah, ctypes.
Well, I guess I have some interesting study ahead of me, to make head or
tail of your solution. Thank you!
--
Steven
More information about the Python-list
mailing list