所以我需要在 pydev 中进行某种类型提示并找到了这个:http://pydev.org/manual_adv_type_hints.html
class MyClass:
def method(self, a):
':type a: ClassA'
这很有魅力。
但是如果我有这样的事情: 类我的类:
def method(self, a, b):
':type a: ClassA'
如何获得两个参数的类型提示? 各种组合我都试过了
':type a,b: ClassA, ClassB
或
':type a, ClassA'
':type b, ClassB'
或
':type a, ClassA, b, ClassB'
有什么建议吗?或者有可能吗?
最佳答案
我注意到它适用于这种格式:
class MyClass:
def method(self, a, b):
#: :type a: ClassA
#: :type b: ClassB
如果您问我,它也更具可读性。我只将 Python 作为业余爱好学习了大约一个星期,所以不要相信我的话。
这种格式的好处是它适用于几乎所有类型的提示(来自 PyDev 手册的示例):
class MyClass:
def method(self, lst):
#Can be on the same line
for a in lst: #: :type a: GUITest
a.;
或
class MyClass:
def method(self, lst):
#Or on the line before
#: :type a: GUITest
for a in lst:
a.;
关于python - 在 pydev 中为几个参数键入提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22693033/