Making your own statements

后端 未结 5 498
情深已故
情深已故 2020-12-21 15:03

Is there a way to define new statements like def, with, for of my own in Python? Of course, I don\'t mean to override the existing sta

5条回答
  •  半阙折子戏
    2020-12-21 15:48

    You can't (re)define language keywords without rewriting a compiler/interpreter/etc. What you could do perhaps is write a something like a DSL (domain-specific language) and something that translates your keyword statements into proper python statements, which might be an easier route.

提交回复
热议问题