What happens when data types are specified?
Annotations in Python are added to code to provide additional information or help to end users with a piece of code while creating libraries. Annotations can be used to add data types to a specific code so that the information on data types can later be retrieved using the annotations by developers.
Type hints as annotations
In the context of typing, which is the topic of this chapter, let’s look at type hints in this section. Data types of a function or method can be defined in Python using a functionality of annotations called type hinting. Type hinting is a concept laid out in PEP 483 (Python Enhancement Proposals) for Python 3.5 by Guido van Rossum and Ivan Levkivskyi. Type hinting can be read in detail in the Python documentation available at PEP 483 – The Theory of Type Hints at peps.python.org. Type hinting is used to provide information to the developers on the data types and return types of Python objects and...