[SciPy-user] help and lazy-import (?)

Arnd Baecker arnd.baecker at web.de
Fri Feb 27 12:24:51 CST 2004


On Fri, 27 Feb 2004, Pearu Peterson wrote:

> On Fri, 27 Feb 2004, Arnd Baecker wrote:
>
> > there there seems to be something weird
> > going on when trying to access help in the following way
> >
> > >>> import scipy
> > >>> help("scipy.linalg")
> > Help on instance of _ModuleLoader in scipy:
> >
> > scipy.linalg = <module 'scipy.linalg' from '/opt/python/lib/pyt...
> > e-packages/scipy/linalg/__init__.pyc' [imported]>
> >
> > Doing another
> > >>> help("scipy.linalg")
> >
> > one gets the expected help.
> >
> > I'd guess that this somehow has to to with the lazy importer of scipy.
> > But maybe there is a workaround?
>
> I get similar behaviour when using ipython.

Well, that's where I first saw this as well
(honestly, I always use ipython ;-)
As I also see this with the normal python prompt
I thought it is un-related to ipython.

> But in a traditional Python prompt
>
> >>> import scipy
> >>> help("scipy.linalg")
>
> I get expected help. This is because ppimport redefines built-in help:
>
> >>> help
> Type help () for interactive help, or help (object) for help about object.
> >>> help.__module__
> 'scipy_base.ppimport'

I get precisely the same output
((to be clear here: apart from that help("scipy.linalg") gives
the above _ModuleLoader message on the first invocation, and only the
second time I get the expected help.))

If this matters:
  - scipy.__version__: '0.2.1_253.3701'
  - Python: 2.3.3

> So, for some reasons, in my case when using ipython, redefined help is
> not effective and probably because help is referenced in ipython before
> importing scipy.

With IPython 0.5.1.cvs I get the same as described above, however with
In [4]: help.__module__
Out[4]: 'site'

> It seems that you are not using ipython, so, what is the
> contents of your PYTHONSTARTUP?

no contents, I don't use it.

What further tests could I do solve this issue ?
(maybe we need further tests by other users to find the origin?)

Many thanks,

Arnd


P.S.: just another "screen shot":

Python 2.3.3 (#1, Feb  3 2004, 22:05:11)
[GCC 3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help.__module__
'site'
>>> import scipy
>>> help.__module__
'scipy_base.ppimport'
>>> help("scipy.linalg")
Help on instance of _ModuleLoader in scipy:

scipy.linalg = <module 'scipy.linalg' from
'/opt/python/lib/pyt...e-packages/sci
py/linalg/__init__.pyc' [imported]>
>>> help("scipy.linalg")

Help on package scipy.linalg in scipy:

NAME
    scipy.linalg

FILE
[..]



More information about the SciPy-user mailing list