3 ms·
> In a dynamic language all values, including expressions, share a single type - a union of all possible types. In a static language you can limit which possibl
by spiralx 9y ago
> In a dynamic language all values, including expressions, share a single type - a union of all possible types. In a static language you can limit which possible types a value may hold. A dynamic language is like if you cast every single type to Any in a static language.
No, you're thinking of a weakly- versus strongly-typed language. Python is dynamically and strongly typed - values have a definite type, but a variable can be assigned a value of any type.
- RussianCow 9y agoI think you misread the OP: they are saying that Python is like a statically typed language in which every value has the type Any. That has nothing to do with strong/weak typing.
- staticassertion 9y agoAs RussianCow said, I think you're misreading my post. A Python variable, from a type perspective, is a variable with a type Any/ a type that is a union of all possible types. Using annotations you can then specify the type. Nothing to do with weak/ strong, which merely imply some level of implicit casting.