Chr*_*s A 0 python parameters autocomplete class visual-studio-code
我有两个类说 A 和 B。 B 在其构造函数 A 作为参数。A 类有一个函数 foo。现在,当我输入“a”时。我希望 Vs 代码自动完成以显示建议“a.foo()”。目前它不起作用。我需要输入提示或类似的东西吗?我试图导入 A 但它不起作用。
class A:
def __init__(self):
def foo(self):
print("hello")
class B:
def __init__(self, a):
a. <-- this should show the members of A but does not
Run Code Online (Sandbox Code Playgroud)
运行 Mac 和带有 Microsoft 扩展的 Python 2.7。
Python 是一种动态类型语言,您的编辑器无法评估a传递给Bbefore 运行时构造函数的参数类型以显示其属性。
您可以使用类型提示来告诉您希望将一个A对象作为参数传递a给 的构造函数B:
def __init__(self, a: A):
在没有类型提示的情况下,您可以使用ctrl(or command)+space查看所有可能的补全。
| 归档时间: |
|
| 查看次数: |
1129 次 |
| 最近记录: |