[SciPy-dev] Postponed imports and docstrings

Pearu Peterson pearu at scipy.org
Wed Nov 3 03:10:30 CST 2004



On Tue, 2 Nov 2004, Fernando Perez wrote:

>> Fernando, could you point out which part of ipython implements `?..`
>> so that I could look into it and fix the in scipy_base/ppimport.py?
>
> Sure, it's mostly done by the code in Magic.py, method _ofind around line 
> 228.   When you type 'foo?', ipython really issues '%pinfo foo', which makes 
> a call to _ofind('foo') to pull out the object pointed to by the name 'foo', 
> along with some info about it.  This is then passed to OInspect's pinfo() 
> method, which builds the full information page.
>
> Note that I tried a bunch of tricks for a couple of hours, trying to repeat 
> the object detection inside _ofind() when scipy objects were involved, but I 
> failed to fix the problem.  So unfortunately, I'll have to defer to you for a 
> proper solution.  I was expecting that perhaps I could toss in a small hack 
> to solve this on the ipython side, but I can't seem to be able to replicate 
> with a simple change the behavior of a repeated 'foo?' call.  This is 
> probably because I don't really understand the delayed import mechanism, and 
> in reality a proper fix in scipy is probably the right approach.

Thanks for the tips. The fix to the problem was simpler: inspect.getdoc 
required a wrapper that applies ppresolve to its argument. Now ?optimize 
works also in first attempt.

Pearu




More information about the Scipy-dev mailing list