How to force static typing in python

lowrin picture lowrin · Jun 27, 2017 · Viewed 8.6k times · Source

Since static typing is available in Python 3.6, is it possible to force static typing for a python project or set of python files?

Answer

hspandher picture hspandher · Jun 27, 2017

You can use annotations in Python3, which might help you get some benefits of static typing.

However if static typing were to be completely enforced in Python, then it won't be Python anymore. It's a duck-typed dynamic language, and would loose all dynamism as a result. If you really intend to use a statically-typed language, you are better off not using Python.