我有这段 Python 代码。在案例 A 中,我没有得到文档字符串,但在案例 B 中,我得到了它。
请建议我让它在案例 A 中工作。谢谢。
from jedi import Script, Interpreter
import math
# Case A
completions = Interpreter(source="math.sin(0)", line=1, column=7, namespaces=[{'math': math}]).completions()
for x in completions:
print(x.docstring()) # Bad. The doc string is always empty.
# Case B
completions = Script(source='import math\nmath.sin(0)', line=2, column=7).completions()
for x in completions:
print(x.docstring()) # Good. Got the doc string.