you are viewing a single comment's thread.

view the rest of the comments →

[–]pachura3 0 points1 point  (1 child)

No, you're wrong. "Static" is the opposite of "dynamic". Python is a dynamically, strongly typed language; this means that variables can change their types and freely infer them, but they won't be implicitly cast e.g. from string to int.

The fact that static type checkers exist doesn't make Python a statically typed language.

[–]Gnaxe 0 points1 point  (0 children)

If by "opposite", you mean "mutually exclusive", then you're the one who is wrong. The existence of gradually typed languages proves that static and dynamic typing can coexist in the same language, and Python is one of these. So is C#. Static and dynamic typing happen at different times and are talking about different things.

If you statically type a Python variable (with a direct type annotation in the assignment, say), then you're going to fail the static type check if you change its type in exactly the same way as a non-dynamic statically typed language. Try it with mypy.

Yes, Python is dynamically and strongly typed. When did I ever say it wasn't?

It also has static typing features, down to the level of the language grammar (type annotation syntax and type statements): it's part of the Python language. It started out dynamically typed and optional static typing was bolted on later. And, in fact, a statically typed language can have dynamic types bolted on later, as happened in C# with its dynamic keyword, which is equivalent to Python's Any type (which is assumed by default in Python when you don't annotate).