Walter Dörwald wrote:
Alex Martelli wrote:
On 12/28/05, Walter Dörwald
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.
And you're on your way to re-writing ipython:
In [1]: x='hello'
In [2]: x?
Type: str
Base Class: