所以我需要在pydev中使用某种类型的提示,并找到了这个:http://pydev.org/manual_adv_type_hints.html

class MyClass:

def method(self, a):
    ':type a: ClassA'


这是一种魅力。

但是,如果我有这样的事情:
    类MyClass:

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/

10-10 14:07
查看更多