Relative Content

Tag Archive for dynamic-typing

Is there a way to prevent variables from changing their type in Python?

It is useful to have the interpreter derive the type of a variable automatically. This on its own is similar to the auto keyword in C++11. However, in Python variables can change their type after being declared for the first time. This potentially can cause a lot of errors. I haven’t seen any reasonable use case for this, besides changing from or to None.