在python里,标识符有字母、数字、下划线组成。
在python中,所有标识符可以包括英文、数字以及下划线(_),但不能以数字开头。python中的标识符是区分大小写的。
以下划线开头的标识符是有特殊意义的。以单下划线开头(_foo)的代表不能直接访问的类属性,需通过类提供的接口进行访问,不能用“from xxx import *”而导入;以双下划线开头的(__foo)代表类的私有成员;以双下划线开头和结尾的(__foo__)代表python里特殊方法专用的标识,如__init__()代表类的构造函数。
flash as3 语法标识符详解
1.在AS3.0中,变量、类和函数都需要一定的名称方可互相区别,并在程序中准确无误的应用。这些有着特定含义的专有名称叫做标识符。
2.按照定义的场所,标识符分为两大类:语言内建标识符和用户自定义标识符。
语言内建标识符:语言内建标识符定义在语言内部。
用户自定义标识符:用户自己创建的名称就是用户自定义标识符.
AS3.0中对标识符的技术限制主要包括以下几点
(1) 所有的标识符大小写敏感。(2) 标识符的首字符必须是英文字母(包括大写或者小写)。(3) 标示符应该由数字(0-9),所有从“A”至“Z”的大写字母、从“a”至“z”的小写字母和下划线“_”构成。(4) 不能与AS3.0k的内建关建字冲突。常见的内建关建字
as
|
break
|
case
|
catch
|
class
|
const
|
continue
|
default
|
delete
|
do
|
else
|
extends
|
typeof
|
finally
|
for
|
function
|
if
|
implements
|
import
|
in
|
instanceof
|
interface
|
internal
|
is
|
native
|
new
|
null
|
package
|
private
|
protected
|
public
|
return
|
super
|
switch
|
this
|
throw
|
to
|
true
|
try
|
use
|
var
|
void
|
while
|
with
|
false
|
应避免合用的关键字
each
|
get
|
set
|
namespace
|
include
|
dynamic
|
final
|
native
|
override
|
static
|
abstract
|
boolean
|
byte
|
cast
|
char
|
debugger
|
double
|
enum
|
export
|
float
|
goto
|
intrinsic
|
long
|
prototype
|
short
|
synchronized
|
throws
|
to
|
transient
|
type
|
virtual
|
volatile
|
dim
|
mx
|
常见的标识符命名错误
合法标识符
|
非法标识符
|
注释
|
fromNo12
|
from#12
|
标识符中不能使用#符号
|
my_Boolean
|
my-Boolean
|
标识符中不能使用“-”符号,应使用“_”代替
|
Obj2
|
2ndObj
|
标识符不能使用数字开头
|
myclass
|
class
|
“class”是内建关键字
|
jack_rose
|
jack&rose
|
符号“&”不能出现在标识符中
|
GUI
|
G.U.I
|
标识符内部不能出现“.”分隔符
|
mybreak()
|
break()
|
“break”是内建关建字不能用于自定义函数名
|