class Product(): attribute = [] def __init__(self, name = None): if name : self.name = name else: self.name = "Unknown" self.description = "None" self.price = 0 def getName(self): return self.name def getDescription(self): return self.description class Attribute(): def __init__(self,product, attr): self.product = product self.product.attribute.append(attr) class Color(): def __init__(self): pass def Red(self): return {'color': 'red'} def Blue(self): return {'color': 'blue'} class Size(): def __init__(self): pass def Small(self): return {'size': 'small'} def Big(self): return {'site': 'big'}
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。