-
Book Overview & Buying
-
Table Of Contents
Hands-On Software Engineering with Python - Second Edition
By :
Starting with the first release of Python 3, the language provided support for type annotation. Specifically, it opened the door for describing, in the code itself, the type-expectations for function and method parameters, and of what a given function or method returns. Since then, the annotation standard has undergone substantial revision, starting with the introduction of the typing module (https://docs.python.org/3.11/library/typing.html) in Python 3.5, and improvements to the syntax allowed for annotation in Python 3.6 through 3.10.
It should be stressed that type annotation in Python, in and of itself, does not provide any direct enforcement of types at runtime. There are packages that can provide runtime type enforcement, but without those additional packages, annotations are little more than additional documentation of the code.
To show the differences, code examples have been written following annotation standards for Python versions from...