[SciPy-dev] Postponed imports and docstrings

Fernando Perez Fernando.Perez at colorado.edu
Tue Nov 2 19:10:29 CST 2004


Pearu Peterson schrieb:

> I'd rather fixing postponed import hooks. For example,
> 
> In [1]: from scipy import *
> 
> In [2]: help(optimize)
> 
> or
> 
> In [2]: info(optimize)
> 
> or
> 
> In [2]: info('optimize')
> 
> work as expected but not
> 
> In [2]: ?optimize
> 
> as you reported.
> 
> 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.

However, let me know if you want any changes in ipython to cooperate with 
scipy's mechanism and make your life easier.

Best,

f




More information about the Scipy-dev mailing list