An attribute reference is a primary followed by a period and a name:
一个属性引用是由一个主元(primary)后跟一个句号和一个名字构成:
attributeref |
::= | primary "." identifier |
The primary must evaluate to an object of a type that supports attribute references, e.g., a module, list, or an instance. This object is then asked to produce the attribute whose name is the identifier. If this attribute is not available, the exception AttributeError is raised. Otherwise, the type and value of the object produced is determined by the object. Multiple evaluations of the same attribute reference may yield different objects.
主元必须是一个支持属性引用的类型的对象.例如, 模块, 列表, 或一个实例. 引用对象属性时, 即要求该被对象生成指定名字的属性. 如果该属性无效, 将会抛出异常AttribError.否则,产生的类型和对象由决定.对同一属性的多次求值是有可能生成不同对象的.