def init(func): #初始化
def wrapper(*args,**kwargs):
g=func(*args,**kwargs)
next(g)
return g
return wrapper
@init
def eater(name):
print(‘%s 准备开始吃饭啦‘ %name)
food_list=[]
while True:
food=yield food_list
print(‘%s 吃了 %s‘ % (name,food))
food_list.append(food)
g=eater(‘egon‘)
g.send(‘蒸羊羔‘)