简体   繁体   English

在pydev中输入提示以获取多个参数

[英]Type hinting in pydev for several parameters

So I am in need of some type hinting in pydev and have found this : http://pydev.org/manual_adv_type_hints.html 因此,我需要在pydev中使用某种类型的提示,并找到了以下内容: http ://pydev.org/manual_adv_type_hints.html

class MyClass:

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

This works as a charm. 这是一种魅力。

However if I have something like this: class MyClass: 但是如果我有这样的东西:class MyClass:

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

How do I get type hints for both parameters? 如何获得两个参数的类型提示? I have tried all kinds of combinations of 我尝试了各种组合

':type a,b: ClassA, ClassB

or 要么

':type a, ClassA'
':type b, ClassB'

or 要么

':type a, ClassA, b, ClassB'

Any suggestions? 有什么建议么? Or is it even possible? 甚至有可能吗?

I've noticed it works with this format: 我注意到它可以使用以下格式:

class MyClass:

    def method(self, a, b):
        #: :type a: ClassA
        #: :type b: ClassB

It's also a bit more readable if you ask me. 如果您问我,它也更具可读性。 I've only been doing Python as a hobby for about a week, so don't take my word for it. 我只是将Python作为一种业余爱好而已,大约一个星期,所以不要相信我。

Nice thing about this format is that it works in for pretty much all type hinting (examples from PyDev manual): 这种格式的好处是,它几乎可以用于所有类型提示(PyDev手册中的示例):

class MyClass:

    def method(self, lst):
        #Can be on the same line
        for a in lst: #: :type a: GUITest
            a.;

or 要么

class MyClass:

    def method(self, lst):
        #Or on the line before
        #: :type a: GUITest
        for a in lst:
            a.;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM