5.python 设计模式-函数式编程-例子
def a():
print(11111)
def b():
print(222222)
class OBJ:
def __init__(self, type):
self.type = type
obj1 = OBJ(1)
obj2 = OBJ(2)
obj3 = OBJ(1)
l = [obj1,obj2,obj3]
trans = {
1: a,
2: b,
}
for i in l:
trans[i.type]()