How to tell pycharm the type of a index variable when looping

已回答

Let's say I am looping through a list of objects:

for object in objects:
    # do something

Is there some way I can inform pycharm as to the type of object so that I get the method auto-completion pops up?

 

0

You can use one of the flavors of Python type hinting. What version of Python are you using?

0

Type hinting in 2.x  example I used recently.

self._children = []
""":type: list[TestResult]"""
0

请先登录再写评论。