What's a type hint for if, after that, the user can actually pass a different type?
What's a type hint for if, after that, the user can actually pass a different type?
Statically typed languages (1) introduce limitations so that type checking is decidable (no incertitude), or (2) or treat "don't know" as "reject", because the runtime has practically no knowledge of type. This is not the case in Python, so you don't have to check everything. That does not mean you shouldn't check anything.
So there are still benefits in Python to have type in order to "reject" code that is undoubtedly going to produce type errors at runtime (or maybe to optimize things). In case of uncertainty, you know the runtime is going to catch errors anyway (including type errors).
I'm sincerely disgusted
Not sure why you say this is throwing away duck typing, you just don't add a type hint and you continue working as usual.
> I'm sincerely disgusted
I can sympathize, most of the time when there is a talk about Lisp there is a guy who comes just to say "dynamic typing is bad", etc. Well, even though there are definitely static analyzers for Lisp (see https://news.ycombinator.com/item?id=12216701), the language is still the same and doesn't prevent anyone from using dynamic features. People who really want statically typed programs won't touch Python anyway so I don't think you have much to worry.
Type hinting would be ok for documentation only. But then, a comment is fine and introduces less clutter.
The warnings that are emitted by SBCL (Lisp implementation) are produced when two types don't intersect at all, something like "len(3)". There is no warning when types overlap. And even if the warning is issued, the code is still compiled and can run.
But I'm inclined to agree. It's a little too to add static typing to Python. You're just going to end up with something far worse than a language that was designed with it in mind, like Ceylon or Go.
Which is nice as some IDEs tend to offer code completion popups OVER the line I'm typing which is very annoying and breaks my thought process.
Also, for _me_, not using code completion helps me think more about what I'm actually doing and not code so much on autopilot. I actually write much better, succinct code without completion.
YMMV
Which statically typed scripting language would you suggest instead of Python?
Would you like something that you can embed? Something that has an interpreter for?
https://en.wikipedia.org/wiki/Scripting_language
> Would you like something that you can embed? Something that has an interpreter for?
I asked about your personal preference regarding a statically typed alternative to Python. Can you propose one?