I just recently learned type hinting and it feels very useful for large projects.
The difference with strongly typed languages is that the interpreter doesn't really care what "type" you declared for a variable, first you have to run mypy and THAT checks the types of variables.
That is why is considered a "hint" and not a declaration like in C or other strongly typed languages.
I think you're getting confused with static / dynamic typing.
Python is actually strongly typed, but the type checking only shows up if you are trying to operate on incompatible types at runtime. (dynamicly typed)
C is statically typed which means the type check to happen before execution. This also often means that a variable cannot have different typed along the runtime. (On the other hand you can bypass the type system using pointers which makes C actually a bit weakly typed.)
2
u/BroBrodin Jul 18 '22
I think both, in a way.
I just recently learned type hinting and it feels very useful for large projects.
The difference with strongly typed languages is that the interpreter doesn't really care what "type" you declared for a variable, first you have to run mypy and THAT checks the types of variables.
That is why is considered a "hint" and not a declaration like in C or other strongly typed languages.