r/Python • • Nov 25 '22

Intermediate Showcase defer in python!

https://github.com/dankeyy/defer.py

stupid but works lol hope you like it

306 Upvotes

62 comments sorted by

View all comments

Show parent comment

7

u/alkasm github.com/alkasm Nov 26 '22

Sorry for the pedantry up front but I think it's worth it here here: var: int is an "annotation", which is part of Python 3 syntax, and not part of the type system. Annotations existed before type checkers were used. It was assumed of course that they would be used for type information, but they also wanted to leave the syntax separated from a specific use case to see what other patterns may emerge from it, though as we know today it is only really used for type checking and for runtime type info in certain libraries. But just pointing out OP isn't abusing the type system, OP is just experimenting with a DSL utilizing the annotation syntax.

1

u/radarsat1 Nov 26 '22

interesting til, thanks