2 ms·
Syntactic support for annotating functions and exposing the annotations existed as of 3.0. The 'typing' module in the standard library was new as of 3.5. Synt
by ubernostrum 9y ago
Syntactic support for annotating functions and exposing the annotations existed as of 3.0.
The 'typing' module in the standard library was new as of 3.5.
Syntactic support for annotating variables was new as of 3.6.
Support for delaying resolution of annotations is new in 3.7 with a __future__ import.
Originally the annotation feature was seen as a possible way to add type hints to Python, but other potential uses were envisioned and no immediate preference was given to types over other uses of annotations.
- viraptor 9y agoWith type comments you can use it in 2.7 as well: https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code https://www.python.org/dev/peps/pep-0484/#suggested-syntax-f... Mypy supports it: http://mypy.readthedocs.io/en/latest/python2.html http://mypy.readthedocs.io/en/latest/python2.html