摘要: class Document: def __init__(self,content): self.t=content def print(self): print(self.t) class Pdf(Document):pass class PrintableMixin: def print(sel 阅读全文
posted @ 2020-10-04 14:57 ascertain 阅读(130) 评论(0) 推荐(0) 编辑
摘要: class Animal: __ORE= 'Animal ore' @classmethod def getore(cls): # 由于是私有属性,所以此处的cls.__ORE已经被解释器替换成cls._Animal_ORE print('class: {}\tclassORE: {}'.forma 阅读全文
posted @ 2020-10-04 14:24 ascertain 阅读(1394) 评论(0) 推荐(0) 编辑
摘要: import math class Shape: @property def area(self): raise NotImplementedError('Base class not implemented') class Triangle(Shape): def __init__(self, a 阅读全文
posted @ 2020-10-04 13:38 ascertain 阅读(260) 评论(0) 推荐(0) 编辑
摘要: class Oar: def __init__(self,oar): self.o=oar def print(self): print(self.o) # print 不会到class Oar下面找,除非引用self.print def decorator(cls): def _print(sel 阅读全文
posted @ 2020-10-04 13:36 ascertain 阅读(385) 评论(0) 推荐(0) 编辑