-
Book Overview & Buying
-
Table Of Contents
Modern Python Cookbook - Third Edition
By :
For the most part, Python’s internal processing will handle a great many simple validity checks properly. If we’ve written a function to convert a string to float, the function will work with float values and string values. It will raise a ValueError exception if we try to apply the float() function to a Path object.
In order for type hints to be optional, run-time type-checking is the minimum level of checking required to make sure some processing can proceed. This is emphatically distinct from the strict checks that tools like mypy make.
Type hints do no run-time processing.
Python (without any add-on packages) does no data type checks or value range checks at run-time. Exceptions are raised when an operator is confronted with a type it can’t process, without regard to the type hints.
This means that Python may be able to process...