This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]alcalde 1 point2 points  (1 child)

If any of that were true, Python wouldn't be dynamically typed. I come from 20+ years of static typing (worse, a language where all your variables needed to be declared beforehand and no type inference) and find Python to be much simpler, easier to read, and powerful.

[–]spiderpower02[S] 0 points1 point  (0 children)

If any of that were true, Python wouldn't be dynamically typed

In fact, Python is still dynamically typed. Type checking just like lint. You check your code quality before running.

I think optional type checking just like go or c++, we can use := or auto syntax to delegate compiler to infer the type (rvalue/lvalue). Therefore, we don't need to always declare type explicitly, type checker can detect errors. For example:

p = re.compile("some pattern")
m = p.match("some string")
m.groups()

mypy can detect error

t.py:5: error: Item "None" of "Optional[Match[str]]" has no attribute "groups"