3 ms·
If I'm not mistaken, all of the types are akin to comments: completely ignored by the interpreter.
by justwalt 7y ago
If I'm not mistaken, all of the types are akin to comments: completely ignored by the interpreter.
- jdm2212 7y agoSo there's the same situation as with TS where you can't do runtime reflection to get type annotations? That seems frustrating. The one really rough edge I've seen in TS is type guards. Not the end of the world, obviously, but still kinda gross coming from Java.
- j88439h84 7y agoYou can get annotations for functions and classes with `typing.get_type_hints()`.
- michael_j_ward 7y agoYou can get type annotations at runtime. And you can use this for validation with something you roll yourself or with 3rd party packages. I've used pydantic [1] before and found it quite nice. [1] https://pydantic-docs.helpmanual.io https://pydantic-docs.helpmanual.io