首页 > 解决方案 > Python 语法中的 FPDEF 和 TFPDEF 是什么意思?

问题描述

我阅读了 Python 的语法文件(https://docs.python.org/3/reference/grammar.html),但我不明白 TFPDEF 和 FPDEF 是什么意思。我希望你能帮帮我 :)

在此处输入图像描述

标签: pythongrammar

解决方案


Python 3.8 版本有更多注释解释它

它们基本上只是NAMEs (T变体有一个可选的类型声明),所以:

def foo(a, b): pass

将通过以下规则子集进行解析:

funcdef: 'def' NAME parameters ':' func_body_suite

parameters: '(' [typedargslist] ')'

typedargslist: tfpdef (',' tfpdef)*

tfpdef: NAME

func_body_suite: simple_stmt

simple_stmt: small_stmt NEWLINE

small_stmt: pass_stmt

推荐阅读