内存高效的python对象
atom的Python项目详细描述
Atom是一个框架,用于创建具有增强的 的动态初始化、验证和更改通知等功能 对象属性。它为 Enaml用户界面框架。
示例:
fromatom.apiimportAtom,Unicode,Range,Bool,observeclassPerson(Atom):""" A simple class representing a person object. """last_name=Unicode()first_name=Unicode()age=Range(low=0)debug=Bool(False)@observe('age')defdebug_print(self,change):""" Prints out a debug message whenever the person's age changes. """ifself.debug:templ="{first} {last} is {age} years old."s=templ.format(first=self.first_name,last=self.last_name,age=self.age,)print(s)def_default_first_name(self):return'John'john=Person(last_name='Doe',age=42)john.debug=Truejohn.age=43# prints messagejohn.age='forty three'# raises TypeError
有关版本信息,请参见the Revision History。