[IPython-dev] PyMAD/IPython which list updated

Fernando Perez Fernando.Perez at colorado.edu
Wed Mar 23 10:16:48 EST 2005

Frédéric Mantegazza wrote:

>>OK, this is easy.  Just make sure that the objects IPython sees have a
>>.getdoc() method; I've added a call to that into my object introspection
>>code. Have a look at inspect.getdoc, you can probably have your .getdoc
>>method be like that, since it does a good job of cleaning up indentation
>>for the docstring.  Your method should conform to the same API as
>>inspect.getdoc: return None if nothing is found, return a string
>>(formatted to your liking) otherwise.
>>In fact, the change is already in CVS, so feel free to play with it.  See
>>OInspect.py's getdoc() function for details.
> It seems to work, but I need some more explanation of the usage, and how 
> things work.
> I'm using the inspect.getdoc() code in my Spectro object. But I would like 
> to have something more accurate. To sumarize:
> obj? should give me the docstring of the class definition of obj.
> obj.method? should give me the docstring of obj.method().
> Is it possible ?

Just have a look at OInspect.getdoc, it shows exactly what is done.  IPython 
will call getdoc() on anything you pass to it, so as long as you provide 
getdoc() in the proper places, you can do anything you want.  This is just a 
protocol for getting information, it's up to you to provide whatever 
information you want over that protocol.

> Last, I tried to use pre-filters, to avoid user deleting some of our 
> objects, but I didn't find documentation about them. Where is it ?


> Prompt is also working fine, but I get some strange behaviour when using 
> multi-lines prompt. Yes, I think that you don't support multi-line prompt, 
> but it works, except:
> - Going up in the history change the color of the prompt (turn back to 
>   white).
> - The indentation for outputs should be computed with the lenght of the last 
>   line of the prompt, and not with all the prompt.
> This is just a remark, but it may not be difficult to solve these problems.

I'm sorry, but I don't see any problems.  With the following:

prompt_in1 '${genutils.getoutput("date")} - In [\#]: '

in my rc file, I get this:

Wed Mar 23 08:14:16 MST 2005 - In [1]: for i in (1,2):
                                   ...:      print i,
1 2

As far as I can see, that's all correct in terms of indentation, and using 
up-arrow doesn't change any colors.  If you have any problems here, please, 
instead of trying to describe it, paste the _exact_ output that you get, along 
with indicating what you think it should be.  There may well be a problem, but 
I simply don't see any in the cases I've tested (and I cant test your actual 
prompt, which depends on all sorts of things which are local to your environment).

> In fact, my first idea before making a dynamic prompt was to have a status 
> bar (dynamically refreshed) at the bottom of IPython, as it is done in 
> minicom, for example. Is it difficult to implement ?

Plain impossible.  IPython is not a curses program, and those things can only 
be done via curses.  A line-oriented program like ipython simply can't do that 
kind of thing, since it has no access to the screen as a 2-d space, only to 
the current line.  You could write a curses wrapper which runs ipython inside 
of it, and does what you want.  But that's clearly beyond what ipython can do, 
because curses is not portable to win32 platforms (and is in general a PITA to 



More information about the IPython-dev mailing list