python - 在 pydev 中为几个参数键入提示

标签 python python-2.7 pydev type-hinting

所以我需要在 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/

相关文章:

java - Java 和 Python 之间的套接字连接 - struct.unpack 错误

python - 转义 Python 中的所有元字符

python - 使用子进程调用时,ssh-keygen 会引发密码太短错误

python - 关于python中的Buffer接口(interface)

python - 套接字错误 : [Errno 32] Broken pipe

python - Supervisord、Flask、Tornado(退出状态 1;不是预期的)

python - 在 Ubuntu 上的 Eclipse Pydev 中使用 Python3 和 Pymongo

python - Docker 与 ubuntu :trusty and installing python-dev

pydev - 如何让 Eclipse Pydev 插件识别新安装的 Python 模块?

python - 有没有办法使用 PyDev 在 Python 中的变量访问上设置断点?