[英]Name delimiter `:` in a meaning way
In the following code:在以下代码中:
In [5]: if 2 > 1 & 1 > 0:
...: print("True")
...:
True
I know that: >
is comparative operator,我知道:
>
是比较运算符,
&
is logic/bitwise operator, &
是逻辑/按位运算符,
=
is assignment operator, =
是赋值运算符,
How about colon :
?冒号怎么样
:
? How could I name it an abstract concept rather than colon:我怎么能把它命名为一个抽象概念而不是冒号:
In [6]: def foo(): return 3
In [7]: foo()
Out[7]: 3
In the above codes, :
act as =
assignment.在上面的代码中,
:
充当=
赋值。
I checked the official docs 2. Lexical analysis — Python 3.6.6 documentation我查了官方文档2.词法分析 — Python 3.6.6 文档
2.6. Delimiters
The following tokens serve as delimiters in the grammar:
( ) [ ] { }
, : . ; @ = ->
+= -= *= /= //= %= @=
&= |= ^= >>= <<= **=
The period can also occur in floating-point and imaginary literals.
I noticed that all the delimiters have appropriate meaning: ( for tuple, [ for list constructor, @ for decorator, ,
for true delimiter, .
for attribute access.我注意到所有的分隔符都有适当的含义:(对于元组,[对于列表构造函数,@对于装饰器
,
对于真正的分隔符, .
对于属性访问。
Excluding :
?排除
:
?
How could I name it in a meaning way?我怎么能以有意义的方式命名它?
:
is simply part of the syntax of a compound statement that indicates the end of the clause header. :
只是复合语句语法的一部分,指示子句标题的结尾。
From the documentation of compound statements :从复合语句的文档中:
Compound statements consist of one or more 'clauses.'
复合语句由一个或多个“子句”组成。 A clause consists of a header and a 'suite.'
子句由标题和“套件”组成。 The clause headers of a particular compound statement are all at the same indentation level.
特定复合语句的子句标题都处于相同的缩进级别。 Each clause header begins with a uniquely identifying keyword and ends with a colon .
每个子句标题都以唯一标识关键字开头,并以冒号结尾。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.