Reputation: 6929
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
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