Danila Ganchar Danila Ganchar - 1 year ago 90
Python Question

Python. Hint for variable

I'm using

as editor. For example, I have next function:

def get_instance():
# method without doc sctring in some module
# returns instance of MyClass
return some_var

And I have second file which calls

var = get_instance()

How I can to define type of data for value? I want to use autocomplete for variable.

For example in
it will be like this:

/** @var MyClass $var */
$var = getInstance();

After this I will be see all methods and properties of
. How to declare docstring for python variable? I know about
, but if I need declare type for specific variable? Can I declare a few types? What I should do?

Note: I can't do any changes with

Answer Source

You can do it in the same way as description properties of class. Here example:

from example_module import MyClass

var = get_instance()
:type var: MyClass
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download