On Sat, Mar 20, 2010 at 5:14 PM, Ingy dot Net <[email protected]> wrote: > Also, I have one specific question: Is it possible to intercept a line from > the Python interactive shell after the user hits enter, but before it is > executed, and then modify it a bit before execution? I was hoping to make > the command 'y ...' translate to 'y(...)' and the command 'y' translate to > 'y(_)'. And stuff like that. I was thinking that the answer might lie in the > readline library, but I can't figure it out.
'ipython' is an enhanced Python shell, so you can see how it does it. You may be able to create a plugin for it. Otherwise 'sys.settrace' or one of the other attributes in 'sys' might help. 'sys.settrace' is a hook to attach a debugger function. -- Mike Orr <[email protected]>
