5 ms·
I don't think you can introduce new syntax in Python and have it run as part of the language, so magic methods, decorators and metaclasses are as good as it get
by goatlover 9y ago
I don't think you can introduce new syntax in Python and have it run as part of the language, so magic methods, decorators and metaclasses are as good as it gets. You'd have to write a parser to handle new syntax, and that makes it external, right?
- klibertp 9y agoYou can also use MacroPy[1] and create embedded DSL with a macro system inspired by Scheme and Elixir. You don't need to write a parser, btw, because the stdlib provides one for you (in `ast` module). [1] https://github.com/lihaoyi/macropy https://github.com/lihaoyi/macropy