[Python-Dev] a quit that actually quits

Fernando Perez fperez.net at gmail.com
Thu Dec 29 17:13:44 CET 2005


Walter Dörwald wrote:

> 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.

And you're on your way to re-writing ipython:

In [1]: x='hello'

In [2]: x?
Type:           str
Base Class:     <type 'str'>
String Form:    hello
Namespace:      Interactive
Length:         5
Docstring:
    str(object) -> string

    Return a nice string representation of the object.
    If the argument is a string, the return value is the same object.

I also started it with "let's add a cool hack to sys.ps1 and sys.displayhook in
10 minutes".  Now we're at 18000 lines of python, a 70 page manual, and growing
suport for remote distributed interactive computing, a new scientific computing
GUI, and more  :)   If you like this kind of thing, by all means join in: I can
use all the helping hands I can get.

Cheers,

f



More information about the Python-Dev mailing list