一个简单的python类结构对象
basicstruct的Python项目详细描述
一个简单的python类结构对象。 与Python2.6+、3.x、PyPy和PyPy3兼容。
安装
pipinstallbasicstruct
用法
To create your own struct, inherit fromBasicStruct
and define the field with the__slots__
class member.BasicStruct
are efficient objects that are automatically comparable, hashable, picklable, printable and reprable.
frombasicstructimportBasicStructclassPoint(BasicStruct):__slots__=('x','y')p1=Point(2,3)p2=Point(1,y=6)p3=Point(x=0,y=0)print(p1)# prints: Point(x=2, y=3)