【发布时间】:2012-04-29 00:55:07
【问题描述】:
假设我有这样的功能:
def render(someobject):
someobject. #here i expect IDE to know which class it is and autocompletion and other IDE functional will be available
dorender()
在我的情况下,IDE 无法知道里面有什么。 如何使用 cmets 来判断?
如果是 PHP,我使用过类似的东西
/**
* @param MyClass myobject
**/
function render($myobject){
//by typing $myobject-> IDE already knows, that it should use $myobject as MyClass objec
dorender()
}
另一个用例是当我知道时,在某些情况下某些代理会返回某些对象 IDE没有机会知道,但我肯定知道并想通过评论指定这一点,以帮助自己将来帮助IDE。
在 PHP 中使用 PhpStorm 我会执行以下操作:
$myobject=some_proxy()
/**
* @var $my_object MyClass
**/
// in following code IDE will use $myobject as MyClass
如何使用 PyCharm 和 python 文档实现相同的行为?
【问题讨论】:
-
在 stackoverflow 找到答案:D 正是我需要的。 stackoverflow.com/questions/6318814/…