会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
魂~
博客园
首页
新随笔
联系
管理
订阅
随笔分类 -
python 设计模式
工厂方法模式
摘要:1 class LeiFeng(object): 2 3 def Sweep(self): 4 print("扫地") 5 6 def Wash(self): 7 print("洗衣") 8 9 def BuyRice(self): 10 print("买米") 11 12 13 class IF...
阅读全文
posted @
2018-01-15 17:02
魂~
阅读(165)
评论(0)
推荐(0)
简单工厂模式
摘要:1 class Operation(): 2 3 def __init__(self, NumberA=0, NumberB=0): 4 self.NumberA = NumberA 5 self.NumberB = NumberB 6 7 def GetResult(self): 8 pass 9 10 ...
阅读全文
posted @
2018-01-15 16:58
魂~
阅读(161)
评论(0)
推荐(0)
单例设计模式
摘要:1 class Singleton(object): 2 3 def __new__(cls, *args, **kwargs): 4 if not hasattr(cls, '_the_instance'): 5 cls._the_instance = object.__new__(cls, *args, **kwargs) 6 ...
阅读全文
posted @
2018-01-15 14:31
魂~
阅读(168)
评论(0)
推荐(0)
公告