函数和keyword/statements有什么区别?

What is the difference between function and keyword/statements?

我看到 'del' 被称为 关键字 声明 。显然,它不被认为是 function:

Python has a del statement (keyword) to delete objects, not a del function.

https://tutorial.eyehunts.com/python/del-function-in-python-code/



我在 Python 中查找了一个函数的定义,它说:

In Python, a function is a group of related statements that performs a specific task.


在这个定义下,我不明白del为什么不能被认为是一个函数。
它确实执行特定任务:删除给定索引处的项目。

语法 似乎不同,因为您不需要括号来使用 del 语句:

motorcycles = ['honda', 'suzuki', 'yamaha']
del motorcycles[0] 

但是 del 是 statement/keyword 而不是函数的其他实际结果是什么?



最后,这里的主要问题是:我如何识别某物是语句而不是函数,反之亦然?

考虑到我必须知道为了了解所需的语法,我认为理解这一点对我来说非常重要。



我做了一些研究,发现了一些关于为什么函数与关键字不同的解释:

Function is a lower designation than a keyword interaction - and in of itself - has to call higher designated System operative calls or akin - to fundamentally interact with memory partitioning.

The main reason for this - is how Python’s hierarchy is constructed in of itself.

但对我来说 - Python 的初学者,其第一编程语言是 R - 这似乎并不能帮助我将某些东西识别为关键字而不是函数。

此外,如果语句不同于关键字,我怎么会看到 del 既被称为语句又被称为关键字?

(What is the difference between a statement and a keyword?)

任何人都可以阐明这一点吗?非常感谢!

Python 关键字本质上是 special reserved words that have specific meanings and purposes and can’t be used for anything but those specific purposes. 它们随 python 标准库一起提供,无论如何您都无法更改它们。你可以阅读更多关于关键字 here 如果你在你的 python 解释器中 运行 help("keywords"),将会返回一堆关键字,del 就是其中之一.

Python 语句引用任何 line/lines 或 python 代码(包括 del motorcycles[0]print(motorcycles[0]) 等内容),它们没有满足任何特定条件才能归类为报表。

Python 函数指的是一段可重复使用的代码,它可以执行某些操作并且每次 运行 时都可以 returns 一个值。它们可以随标准库一起提供,也可以由用户定义。关于函数的更多信息可以参考this

python 中的

Del 是关键字,因为它做了普通 python 函数不能做的事情:它与底层内存交互并从内存中解除变量的绑定。它是用 CPython.

实现的