2 ms·
> In Python, type annotations have no impact on runtime behavior That's true of any "scripting" language types. E.g. TypeScript const x: number = 0n; // s
by paulddraper 7mo ago
> In Python, type annotations have no impact on runtime behavior
That's true of any "scripting" language types.
E.g. TypeScript
const x: number = 0n; // still is a bigint
Granted, in both the Python and the TypeScript example, the type checker will complain at your incorrect type annotation.
- dgrunwald 7mo agoBut in Python the type checker does not complain about `x: float = 0`, because for the purpose of type checking (but not at runtime), `int` is considered a subtype of `float`: https://typing.python.org/en/latest/spec/special-types.html#special-cases-for-float-and-complex https://typing.python.org/en/latest/spec/special-types.html#...