17xie > Python 语言参考手册 > 2.3 标识符和关键字 Identifiers and keywords
背景:                 
[本书目录] [图书首页] [本书讨论区]  
链接地址:http://www.17xie.com/read-37409.html    注册17xie 一起来写书 实现您的出书梦想!


2.3 标识符和关键字 Identifiers and keywords

Identifiers (also referred to as names) are described by the following lexical definitions:

标识符(也叫做名字)由以下词法定义描述:

identifier  ::=  (letter|"_") (letter | digit | "_")*
letter  ::=  lowercase | uppercase
lowercase  ::=  "a"..."z"
uppercase  ::=  "A"..."Z"
digit  ::=  "0"..."9"
Download entire grammar as text.

Identifiers are unlimited in length. Case is significant.

标识符不限长, 区分大小写.



2.3.1 关键字 Keywords

The following identifiers are used as reserved words, or keywords of the language, and cannot be used as ordinary identifiers. They must be spelled exactly as written here:

以下标识符用作保留字, 或者叫做语言的关键字, 并且不能作为普通标识符使用, 而且它们必须像下面的那样严格拼写.

and       del       for       is        raise    
assert    elif      from      lambda    return   
break     else      global    not       try      
class     except    if        or        while    
continue  exec      import    pass      yield    
def       finally   in        print

Note that although the identifier as can be used as part of the syntax of import statements, it is not currently a reserved word.

In some future version of Python, the identifiers as and None will both become keywords.



2.3.2 保留的标识符类型 Reserved classes of identifiers

Certain classes of identifiers (besides keywords) have special meanings. These classes are identified by the patterns of leading and trailing underscore characters:

(关键字以外的)某些类型的标识符具有特殊的含义, 如下:

_*
Not imported by "from module import *". The special identifier "_" is used in the interactive interpreter to store the result of the last evaluation; it is stored in the __builtin__ module. When not in interactive mode, "_" has no special meaning and is not defined. See section 6.12, ``The import statement.''

不能通过" from moduls import *"导入。 特定标识符"_"在交互式解释器用于存储上次估值的结果. 它位于__buildin__模块之中. 在非交互方式时,"_"没有特殊含义, 且是未定义的

Note: The name "_" is often used in conjunction with internationalization; refer to the documentation for the gettext module for more information on this convention.

__*__
System-defined names. These names are defined by the interpreter and it's implementation (including the standard library); applications should not expect to define additional names using this convention. The set of names of this class defined by Python may be extended in future versions. See section 3.3, ``Special method names.''

系统定义的名字

__*
Class-private names. Names in this category, when used within the context of a class definition, are re-written to use a mangled for to help avoid name clashes between ``private'' attributes of base and derived classes. See section 5.2.1, ``Identifiers (Names).''

类私有名字


字数:2764    最后更新:8个月以前 [03-15 20:19]月落晨星 修改
本页编辑者:月落晨星  
[前一页]:2.2 其它语言符号 Oth…  [后一页]:2.4 字面值 Literals
[在本页中加入书签] [收藏本书] [推荐本书]
  17xie论坛 > 本书讨论区 > 本页评论   (共0条)
发表评论

用户名称 匿名发表
评论内容
验证码

关于我们 | 版权声明 | 免责声明 | 诚聘英才 | 联系我们 | 合作伙伴 | 友情链接 | 广告合作 | 提交意见
Copyright © 2007 17xie.com 互联网协同写书平台 京ICP备08002671号