python : Any use of this assignment to an empty list?

标签 python scipy

示例代码表单scipy document :

from scipy.stats import norm
numargs = norm.numargs
[  ] = [0.9,] * numargs
rv = norm()

我完全不明白第三行在这里做什么。谁能解释一下吗?

最佳答案

我称这为恶作剧。因此 numargs 的类型为 int,如果它是 0 以外的任何类型,则此代码将失败。本质上,这段代码只是 []=[],对我来说这似乎完全没有意义。

这可能只是文档中的遗留内容,因为其他地方会出现以下内容:

>>> from scipy.stats import nct
>>> numargs = nct.numargs
>>> [ df, nc ] = [0.9,] * numargs
>>> rv = nct(df, nc)

也许这些示例是自动生成的。由于所有其他发行版示例都具有类似的格式。

关于 python : Any use of this assignment to an empty list?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22729421/

相关文章:

python - ‘NoneType’的对象没有len()-错误

python - 如何在 Pygame 中添加文本语音

python - 在 Ubuntu 中安装最新的 scipy (0.9)?

python - 如何将 pyinstaller 与隐藏导入一起用于 scipy.optimize leastsq

python - Scipy 树状图的简单着色

python - 从字典中获取单个键的最佳方法?

python - 如何使用 Windows 从 tar 文件中读取特定文件?

Python:根据 Scipy 的 3D Delaunay 三角剖分计算 Voronoi Tesselation

python - 将 cython 函数与 cython 方法传递给 scipy.integrate

python - 我的 Python 3x 代码有什么问题?