做出自己的陈述 [英] Making your own statements

查看:100
本文介绍了做出自己的陈述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以用Python定义自己的新语句,例如defwithfor?当然,我并不是要覆盖现有的语句,而只是创建一些我自己的语句.

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 statements, only create some of my own.

如果是,该怎么办?您能指出我有关该主题的好文档吗?

If so, how do I do it? Can you point me to good docs on the subject?

推荐答案

否,您不能在Python程序中添加新语法.更改语言的唯一方法是编辑并重新编译语法文件并支持C代码,以获得新的更改后的解释器,编译器和运行时.

No, you cannot add new syntax within a Python program. The only way to alter the language is to edit and recompile the grammar file and supporting C code, to obtain a new altered interpreter, compiler and runtime.

这篇关于做出自己的陈述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆