如果你区分物体,你就会发现它们不一样的原因。
diff的Python项目详细描述
diff定义了一个差异协议。观看:
>>>classLonelyObject(object):...def__diff__(self,other):...return"{} is not like {}".format(self,other)......def__repr__(self):...return"<LonelyObject>">>>fromdiffimportdiff>>>diff(LonelyObject(),12).explain()'<LonelyObject> is not like 12'