Remix.run Logo
shevy-java 3 hours ago

But you use types not to communicate with other people - you use them to give more hints to the python interpreter. Otherwise you could use comments. :)

zem 2 hours ago | parent [-]

type annotations in python are essentially structured comments with special syntactic support and runtime introspection facilities (i.e. you can get at the annotations from within the code). they are explicitly not "types" as far as the interpreter is concerned, you can say e.g. `x: str = 42` and python will be fine with it. the value comes from tooling like type checkers and LSPs that work with the annotations, and from metaprogramming libraries like dataclasses and pydantic that introspect them at runtime and use them to create classes etc.