IPython和__doc__

时间:2013-06-28 02:12:08

标签: python-2.7 ipython

我正在使用从“Enthought Python Distribution”

下载的IPython

在IPython / Python 2.7.3下,当我输入help(__doc__)时,结果为:

In  [26]: help(__doc__)
no Python documentation found for 'Automatically created module for IPython interactive environment'

这个结果是什么意思? IPython不支持?

谢谢!

1 个答案:

答案 0 :(得分:1)

正如@Blender所说,__doc__只是一个字符串,通常是给定函数或模块的帮助字符串。例如,

In [1]: numpy.__doc__
Out[1]: '\nNumPy\n=====\n\nProvides\n  1. An array object of arbitrary homogeneous items\n  2. Fast mathematical operations over arrays\n ...

numpy模块的帮助字符串。在help()上调用numpy基本上只打印出一个格式良好的字符串版本:

Help on package numpy:

NAME
    numpy

FILE
    /usr/lib64/python2.6/site-packages/numpy/__init__.py

DESCRIPTION
    NumPy
    =====

    Provides
      1. An array object of arbitrary homogeneous items
      2. Fast mathematical operations over arrays
      ...

在IPython中,字符串__doc__只是:

In [3]: __doc__
Out[3]: 'Automatically created module for IPython interactive environment'

调用help(__doc__)然后查找不存在的__doc__.__doc__