BuZZ-dEE
BuZZ-dEE

Reputation: 6929

How to document a Python variable?

How can I document a variable in Python. In JavaScript / JSDoc I can do something like that.:

/** @type {Array<Number>} */
var foo;
/** @type {Number[]} */
var bar;

Some IDEs than can give better code completion.

Is this also possible in Python?

Upvotes: 0

Views: 139

Answers (1)

Joran Beasley
Joran Beasley

Reputation: 113950

x, y, z = [], [], [] # type: (List[int], List[int], List[str]) is how it is defined in the spec ... your particular IDE may or may not implement it in this way ...

see also: https://www.python.org/dev/peps/pep-0484/#type-comments

Upvotes: 1

Related Questions