중첩 함수의 지역 변수 좋아요, 이것에 대해 참아주세요. 끔찍하게 복잡해 보일 것이라는 것을 압니다.하지만 무슨 일이 일어나고 있는지 이해하도록 도와주세요. from functools import partial class Cage(object): def __init__(self, animal): self.animal = animal def gotimes(do_the_petting): do_the_petting() def get_petters(): for animal in ['cow', 'dog', 'cat']: cage = Cage(animal) def pet_function(): print "Mary pets the " + cage.animal + "." yield (animal, partial(got..