also I just realized that Brazil did NOT make a programming language entirely in Spanish and call it “Si” and that my professor was making a joke about C… god damn it
this post is probably too nieche but I feel like Lemmy is nerdy enough that enough people will get it lol
You can in fact statically type in Python. For example, defining variables:
six: int = 6 hello_world: str = "Hello World!"
Or defining functions:
def foo(x: int) -> int: return x**2
If you only want to use static Python, you can use the mypy static checker:
That’s just a fancy way of commenting on the intended types, no static typing though.
Python will happily execute:
six: int = 6 six = "Hello World!"
But mypy will not accept it :)
What you’re describing is type hints, it’s syntactic sugar and not used at all by the interpreter.
For example, this is a “legal” statement:
foo: int = "bar"
Your IDE and linter will complain, but the interpreter just chops the hints off when compiling, and it’s left with
foo = "bar"
I was using that syntax, but nothing seemed to be checking it. Running an external app to get static checking done isn’t great, presumably there are extensions for common IDEs?
But the poor vscode developer experience went beyond that. I attribute it to dynamic typing because most of my frustration was with the IDE’s inability to tell me the type of a given variable, and what functions/properties were accessable on it.
I hope it’d be better on an IDE made specifically for python, although idk how many extensions I’d have to give up for it, and things like devcontainers.
Yeah, vscode is too laggy.