正在加载图片...
New dot expression rules <expression>.<name> How to evaluate: 1.Evaluate <expression>,which yields an object. 2.<name>is matched against the instance attributes of that object;if an attribute with that name exists,its value is returned. 3.If not,the name is looked up in the class,which yields a class attribute value.If it is not found in the class,look in any superclasses. 4.That value is returned unless it is a function,in which case a bound method is returned instead. >>luxio ElectricType('Luxio','Alex') >>luxio.hp Found in instance 50 >>luxio.damage Found in Pokemon class 40 >>luxio.basic_attack Found in ElectricType class 'thunder shock'New dot expression rules <expression>.<name> How to evaluate: 1. Evaluate <expression>, which yields an object. 2. <name> is matched against the instance attributes of that object; if an attribute with that name exists, its value is returned. 3. If not, the name is looked up in the class, which yields a class attribute value. If it is not found in the class, look in any superclasses. 4. That value is returned unless it is a function, in which case a bound method is returned instead. >>> luxio = ElectricType('Luxio', 'Alex') >>> luxio.hp # Found in instance 50 >>> luxio.damage # Found in Pokemon class 40 >>> luxio.basic_attack # Found in ElectricType class 'thunder shock
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有